Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtEquNo.Text.Trim() == "")
            {
                SetTipsInfo(false, "设备编号不能为空!");
                txtEquNo.Focus();
                txtEquNo.SelectAll();
                return;
            }
            if (txtEquName.Text.Trim() == "")
            {
                SetTipsInfo(false, "设备名称不能为空!");
                txtEquName.Focus();
                txtEquName.SelectAll();
                return;
            }
            //判断设备编号是否重复
            if (Frmoperator == 0 || (Frmoperator == 1 && !txtEquNo.Text.Trim().Equals(strEquNO)))
            {
                if (bll.IsExitsEquNo(txtEquNo.Text))
                {
                    SetTipsInfo(false, "编号已存在!");
                    txtEquNo.Focus();
                    txtEquNo.SelectAll();
                    return;
                }
            }

            if (Frmoperator == 0)                   //新增
            {
                int    deptid    = int.Parse(cmbEquDept.SelectedValue);
                int    equtype   = int.Parse(cmbEqutype.SelectedValue);
                int    equstate  = int.Parse(cmbEqustate.SelectedValue);
                int    factoryid = int.Parse(cmbEqufactory.SelectedValue);
                string DeptName  = cmbEquDept.Text;
                if (bll.InsertEquBaseInfo(txtEquNo.Text, txtEquName.Text, deptid, DeptName, equtype, equstate, factoryid, txtEquRemark.Text))
                {
                    string modelspecial = txtModelSpecial.Text;
                    string dutyemployee = txtDutyEmployee.Text;
                    string userange     = txtUserange.Text;
                    string prodate      = "null";
                    string usedate      = "null";
                    if (checkBox1.Checked)
                    {
                        prodate = "'" + dtpProductDate.Value.ToString("yyyy-MM-dd") + "'";
                    }
                    if (checkBox2.Checked)
                    {
                        usedate = "'" + dtpUseDate.Value.ToString("yyyy-MM-dd") + "'";
                    }
                    string height = "null";
                    string kw     = "null";
                    if (txtEquHeight.Text != "")
                    {
                        height = txtEquHeight.Text;
                    }
                    if (txtEquKw.Text != "")
                    {
                        kw = txtEquKw.Text;
                    }
                    bll.InsertEquDetailInfo(txtEquNo.Text, modelspecial, dutyemployee, userange, prodate, height, kw, usedate);
                    SetTipsInfo(true, "保存成功!");


                    //Czlt-2011-12-10 跟新时间
                    bll.UpdateTime();

                    frmeqm.Flash();
                }
                else
                {
                    SetTipsInfo(false, "保存失败!");
                }
            }
            if (Frmoperator == 1)                   //修改
            {
                int    deptid    = int.Parse(cmbEquDept.SelectedValue);
                int    equtype   = int.Parse(cmbEqutype.SelectedValue);
                int    equstate  = int.Parse(cmbEqustate.SelectedValue);
                int    factoryid = int.Parse(cmbEqufactory.SelectedValue);
                string DeptName  = cmbEquDept.Text;
                if (bll.UpdateEquBaseInfo(txtEquNo.Text, txtEquName.Text, deptid, DeptName, equtype, equstate, factoryid, txtEquRemark.Text, strEquID))
                {
                    bll.UpdateEquDetailInfo(strEquID, txtModelSpecial.Text, txtDutyEmployee.Text, txtUserange.Text, dtpProductDate.Value, txtEquHeight.Text, txtEquKw.Text, dtpUseDate.Value);
                    strEquNO = txtEquNo.Text.Trim();
                    SetTipsInfo(true, "保存成功!");


                    //Czlt-2011-12-10 跟新时间
                    bll.UpdateTime();

                    frmeqm.Flash();
                }
                else
                {
                    SetTipsInfo(false, "保存失败!");
                }
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtFNo.Text.Trim() == "")
            {
                SetTipsInfo(false, "编号不能为空!");
                txtFNo.Focus();
                txtFNo.SelectAll();
                return;
            }
            if (txtFName.Text.Trim() == "")
            {
                SetTipsInfo(false, "名称不能为空!");
                txtFName.Focus();
                txtFName.SelectAll();
                return;
            }
            //验证设备编号是否相同
            if (frmoperator == 0 || (frmoperator != 0 && !txtFNo.Text.Trim().Equals(strFactoryNO)))
            {
                if (bll.isExitsFactory(txtFNo.Text))
                {
                    SetTipsInfo(false, "编号已存在,请重新输入!");
                    txtFNo.Focus();
                    txtFNo.SelectAll();
                    return;
                }
            }

            if (frmoperator == 0)
            {
                if (bll.InsertFactory(txtFNo.Text, txtFName.Text, txtFaddress.Text, txtFfex.Text, txtFtel.Text, txtFemp.Text, txtFemptel.Text, txtFremark.Text))
                {
                    SetTipsInfo(true, "保存成功!");


                    //Czlt-2011-12-10 跟新时间
                    bll.UpdateTime();
                    frmeqm.Flash();
                }
                else
                {
                    SetTipsInfo(false, "保存失败!");
                }
            }
            else
            {
                if (bll.UpdateFactory(txtFNo.Text, txtFName.Text, txtFaddress.Text, txtFfex.Text, txtFtel.Text, txtFemp.Text, txtFemptel.Text, txtFremark.Text, strFactoryID))
                {
                    strFactoryNO = txtFNo.Text.Trim();
                    SetTipsInfo(true, "保存成功!");

                    //Czlt-2011-12-10 跟新时间
                    bll.UpdateTime();
                    frmeqm.Flash();
                }
                else
                {
                    SetTipsInfo(false, "保存失败!");
                }
            }
        }