コード例 #1
0
        private void Save()
        {
            txtName.Focus();
            string cmd     = string.Empty;
            bool   sw      = false;
            bool   swPhase = false;

            if (lblPhase.Text != "0")
            {
                cmd    += string.Format("({0}*{1})", lblPhase.Text, txtPhaseCross.Text);
                sw      = true;
                swPhase = true;
            }
            if (txtNeutralCross.Text != "0")
            {
                if (sw)
                {
                    cmd += " + ";
                }
                cmd += string.Format("{0}", txtNeutralCross.Text);
                sw   = true;
            }

            if (swPhase)
            {
                //if (sw)
                //    cmd += " + ";
                cmd += "  " + string.Format("{0}", txtType.Text);
                sw   = true;
            }

            cmd += "  Cable Ground";

            //if (swPhase)
            //{
            //    cmd += "  " + lblMaterialCode.Text;
            //}

            ed.WriteMessage(cmd + "\n");
            Atend.Base.Equipment.EGroundCabelTip GroundCabeltip = new Atend.Base.Equipment.EGroundCabelTip();
            GroundCabeltip.Name         = txtName.Text;
            GroundCabeltip.PhaseCount   = Convert.ToInt32(cboPhaseCount.SelectedItem.ToString());
            GroundCabeltip.NeutralCount = Convert.ToInt32(cboNeutralCount.SelectedItem.ToString());
            //GroundCabeltip.NightCount = Convert.ToInt32(cboNightCount.SelectedItem.ToString());
            GroundCabeltip.NeutralProductXCode = new Guid(cboNeutralProductCode.SelectedValue.ToString());
            GroundCabeltip.PhaseProductXCode   = new Guid(cboPhaseProductCode.SelectedValue.ToString());
            //GroundCabeltip.NightProductXCode = new Guid(cboNightProductCode.SelectedValue.ToString());
            GroundCabeltip.Description = cmd;
            GroundCabeltip.IsDefault   = IsDefault;
            //ed.WriteMessage("Go To Insert\n");
            GroundCabeltip.Code = Code;
            if (SelectGroundCabelTipXCode == Guid.Empty)
            {
                if (GroundCabeltip.InsertX())
                {
                    Reset();
                }
                else
                {
                    MessageBox.Show("امکان ثبت اطلاعات نمی باشد", "خطا");
                }
            }
            else
            {
                GroundCabeltip.XCode = SelectGroundCabelTipXCode;
                if (GroundCabeltip.UpdateX())
                {
                    Reset();
                }
                else
                {
                    MessageBox.Show("امکان به روز رسانی اطلاعات نمی باشد", "خطا");
                }
            }
        }