在CakePHP 3.0中调用PostgreSQL存储过程

时间:2015-10-02 11:12:25

标签: postgresql cakephp plpgsql cakephp-3.0

我正在使用PostgreSQL数据库在CakePHP 3中开发我的新项目。我创建了一些存储过程。我试图使用下面的代码在cakePHP 3.0中调用它们。但不确定,这是否是正确的方法。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Ükran
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private bool Kran = false;


        // Codeoptimierung: (optimize code)

        private void checkKranIstAn()
        {
            if(Kran == true)
            {
                lblAnzeige.Text = " ";
                return;
            } else
            {
                lblAnzeige.Text = "Der Kran wurde noch nicht angeschaltet! Bitte anschalten!";
                return;
            }

        }

        //method with if else statement that should be replaced
        private void cmdHakenRaus_Click(object sender, EventArgs e)
        {
            if (Kran == true)
            {
                panel4.Size = new Size(panel4.Width = panel4.Width, panel4.Height = panel4.Height + 10);

            } else
            {
                lblAnzeige.Text = "Der Kran wurde noch nicht angeschaltet! Bitte anschalten!";
            }
        }

        //THIS! here i tried it but didnt know how to do it the right way
        private void cmdHakenRein_Click(object sender, EventArgs e)
        {
            checkKranIstAn();
            panel4.Size = new Size(panel4.Width = panel4.Width, panel4.Height = panel4.Height - 10);
        }

        private void cmdAuslegerRaus_Click(object sender, EventArgs e)
        {
            panel3.Location = new Point(panel3.Location.X - 10, panel3.Location.Y);
            panel4.Location = new Point(panel4.Location.X - 10, panel4.Location.Y);
            panel3.Size = new Size(panel3.Width = panel3.Width + 10, panel3.Height);
        }

        private void cmdAuslegerRein_Click(object sender, EventArgs e)
        {
            panel3.Location = new Point(panel3.Location.X + 10, panel3.Location.Y);
            panel4.Location = new Point(panel4.Location.X + 10, panel4.Location.Y);
            panel3.Size = new Size(panel3.Width = panel3.Width - 10, panel3.Height);
        }

        private void cmdKranRechts_Click(object sender, EventArgs e)
        {
            panel1.Location = new Point(panel1.Location.X - 10, panel1.Location.Y);
            panel2.Location = new Point(panel2.Location.X - 10, panel2.Location.Y);
            panel3.Location = new Point(panel3.Location.X - 10, panel3.Location.Y);
            panel4.Location = new Point(panel4.Location.X - 10, panel4.Location.Y);
        }

        private void cmdKranLinks_Click(object sender, EventArgs e)
        {
            panel1.Location = new Point(panel1.Location.X + 10, panel1.Location.Y);
            panel2.Location = new Point(panel2.Location.X + 10, panel2.Location.Y);
            panel3.Location = new Point(panel3.Location.X + 10, panel3.Location.Y);
            panel4.Location = new Point(panel4.Location.X + 10, panel4.Location.Y);
        }

        private void cmdKranAus_Click(object sender, EventArgs e)
        {
            Kran = false;
        }

        private void cmdKranEin_Click(object sender, EventArgs e)
        {
            Kran = true;
        }

        private void cmdEnde_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}

请建议是否有更好的方法来做到这一点。

0 个答案:

没有答案