Beispiel #1
0
        public int EditModel(IModel model)
        {
            UCWDB800 objModel = (UCWDB800)model;
            //编写带参数的SQL语句
            StringBuilder sqlBuilder = new StringBuilder();

            sqlBuilder.Append("Update UCWDB800 set Length=@Length,ExRightDis=@ExRightDis,ExLength=@ExLength,ExWidth=@ExWidth,ExHeight=@ExHeight,");
            sqlBuilder.Append("FCSide=@FCSide,FCSideLeft=@FCSideLeft,FCSideRight=@FCSideRight,FCBlindNo=@FCBlindNo,");
            sqlBuilder.Append("SidePanel=@SidePanel,DPSide=@DPSide,LightType=@LightType,UVType=@UVType,SensorNo=@SensorNo,SensorDis1=@SensorDis1,SensorDis2=@SensorDis2,");
            sqlBuilder.Append("SSPType=@SSPType,Gutter=@Gutter,GutterWidth=@GutterWidth,ANSUL=@ANSUL,ANSide=@ANSide,");
            sqlBuilder.Append("MARVEL=@MARVEL,Japan=@Japan where UCWDB800Id=@UCWDB800Id");
            //定义参数数组
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@Length", objModel.Length),
                new SqlParameter("@ExRightDis", objModel.ExRightDis),
                new SqlParameter("@ExLength", objModel.ExLength),
                new SqlParameter("@ExWidth", objModel.ExWidth),
                new SqlParameter("@ExHeight", objModel.ExHeight),

                new SqlParameter("@FCSide", objModel.FCSide),
                new SqlParameter("@FCSideLeft", objModel.FCSideLeft),
                new SqlParameter("@FCSideRight", objModel.FCSideRight),
                new SqlParameter("@FCBlindNo", objModel.FCBlindNo),
                new SqlParameter("@SidePanel", objModel.SidePanel),
                new SqlParameter("@LightType", objModel.LightType),

                new SqlParameter("@UVType", objModel.UVType),
                new SqlParameter("@SensorNo", objModel.SensorNo),
                new SqlParameter("@SensorDis1", objModel.SensorDis1),
                new SqlParameter("@SensorDis2", objModel.SensorDis2),

                new SqlParameter("@DPSide", objModel.DPSide),
                new SqlParameter("@SSPType", objModel.SSPType),
                new SqlParameter("@Gutter", objModel.Gutter),
                new SqlParameter("@GutterWidth", objModel.GutterWidth),
                new SqlParameter("@ANSUL", objModel.ANSUL),
                new SqlParameter("@ANSide", objModel.ANSide),

                new SqlParameter("@MARVEL", objModel.MARVEL),
                new SqlParameter("@Japan", objModel.Japan),

                new SqlParameter("@UCWDB800Id", objModel.UCWDB800Id)
            };
            try
            {
                return(SQLHelper.Update(sqlBuilder.ToString(), param));
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库操作出现异常:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public IModel GetModelByWhereSql(string whereSql)
        {
            string sql =
                "select UCWDB800Id,ModuleTreeId,Length,ExRightDis,ExLength,ExWidth,ExHeight," +
                "FCSide,FCSideLeft,FCSideRight,FCBlindNo,SidePanel,DPSide,LightType,UVType,SensorNo,SensorDis1,SensorDis2," +
                "SSPType,Gutter,GutterWidth,ANSUL,ANSide,MARVEL,Japan from UCWDB800";

            sql += whereSql;
            SqlDataReader objReader = SQLHelper.GetReader(sql);
            UCWDB800      objModel  = null;

            if (objReader.Read())
            {
                objModel = new UCWDB800()
                {
                    UCWDB800Id   = Convert.ToInt32(objReader["UCWDB800Id"]),
                    ModuleTreeId = Convert.ToInt32(objReader["ModuleTreeId"]),
                    //最好不要用=null去判断,提示类型转换错误
                    Length     = objReader["Length"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["Length"]),
                    ExRightDis = objReader["ExRightDis"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExRightDis"]),
                    ExLength   = objReader["ExLength"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExLength"]),
                    ExWidth    = objReader["ExWidth"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExWidth"]),
                    ExHeight   = objReader["ExHeight"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["ExHeight"]),

                    FCSide      = objReader["FCSide"].ToString().Length == 0 ? "" : objReader["FCSide"].ToString(),
                    FCSideLeft  = objReader["FCSideLeft"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["FCSideLeft"]),
                    FCSideRight = objReader["FCSideRight"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["FCSideRight"]),
                    FCBlindNo   = objReader["FCBlindNo"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["FCBlindNo"]),

                    SidePanel = objReader["SidePanel"].ToString().Length == 0 ? "" : objReader["SidePanel"].ToString(),
                    DPSide    = objReader["DPSide"].ToString().Length == 0 ? "" : objReader["DPSide"].ToString(),
                    LightType = objReader["LightType"].ToString().Length == 0 ? "" : objReader["LightType"].ToString(),

                    UVType     = objReader["UVType"].ToString().Length == 0 ? "" : objReader["UVType"].ToString(),
                    SensorNo   = objReader["SensorNo"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["SensorNo"]),
                    SensorDis1 = objReader["SensorDis1"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["SensorDis1"]),
                    SensorDis2 = objReader["SensorDis2"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["SensorDis2"]),

                    SSPType     = objReader["SSPType"].ToString().Length == 0 ? "" : objReader["SSPType"].ToString(),
                    Gutter      = objReader["Gutter"].ToString().Length == 0 ? "" : objReader["Gutter"].ToString(),
                    GutterWidth = objReader["GutterWidth"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["GutterWidth"]),

                    ANSUL  = objReader["ANSUL"].ToString().Length == 0 ? "" : objReader["ANSUL"].ToString(),
                    ANSide = objReader["ANSide"].ToString().Length == 0 ? "" : objReader["ANSide"].ToString(),
                    MARVEL = objReader["MARVEL"].ToString().Length == 0 ? "" : objReader["MARVEL"].ToString(),
                    Japan  = objReader["Japan"].ToString().Length == 0 ? "" : objReader["Japan"].ToString(),
                };
            }
            objReader.Close();
            return(objModel);
        }
Beispiel #3
0
        public FrmUCWDB800(Drawing drawing, ModuleTree tree) : this()
        {
            objUCWDB800 = (UCWDB800)objUCWDB800Service.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());
            if (objUCWDB800 == null)
            {
                return;
            }
            this.Text = drawing.ODPNo + " / Item: " + drawing.Item + " / Module: " + tree.Module + " - " + tree.CategoryName;
            Category objCategory = objCategoryService.GetCategoryByCategoryId(tree.CategoryId.ToString());

            pbModelImage.Image = objCategory.ModelImage.Length == 0
                ? Image.FromFile("NoPic.png")
                : (Image) new SerializeObjectToString().DeserializeObject(objCategory.ModelImage);
            FillData();
        }
Beispiel #4
0
        private void btnEditData_Click(object sender, EventArgs e)
        {
            #region 数据验证
            //必填项目
            if (pbModelImage.Tag.ToString().Length == 0)
            {
                return;
            }
            if (!DataValidate.IsDecimal(txtLength.Text.Trim()) || Convert.ToDecimal(txtLength.Text.Trim()) < 100m)
            {
                MessageBox.Show("请认真检查烟罩长度", "提示信息");
                txtLength.Focus();
                txtLength.SelectAll();
                return;
            }
            //排风腔位置
            if (cobSidePanel.SelectedIndex == -1)
            {
                MessageBox.Show("请选择烟罩位置", "提示信息");
                cobSidePanel.Focus();
                return;
            }
            //ANSUL腔
            if (cobGutter.SelectedIndex == -1)
            {
                MessageBox.Show("请选择是否右ANSUL腔", "提示信息");
                cobGutter.Focus();
                return;
            }
            else if (cobGutter.SelectedIndex == 0 && (!DataValidate.IsDecimal(txtGutterWidth.Text.Trim()) || Convert.ToDecimal(txtGutterWidth.Text.Trim()) < 30m))
            {
                MessageBox.Show("请认真检查ANSUL腔宽度", "提示信息");//当脖颈大于2时需要填写脖颈间距
                txtGutterWidth.Focus();
                txtGutterWidth.SelectAll();
                return;
            }

            //脖颈
            if (!DataValidate.IsDecimal(txtExLength.Text.Trim()) || Convert.ToDecimal(txtExLength.Text.Trim()) < 50m)
            {
                MessageBox.Show("请填写脖颈长度", "提示信息");
                txtExLength.Focus();
                txtExLength.SelectAll();
                return;
            }
            if (!DataValidate.IsDecimal(txtExWidth.Text.Trim()) || Convert.ToDecimal(txtExWidth.Text.Trim()) < 50m)
            {
                MessageBox.Show("请填写脖颈宽度", "提示信息");
                txtExWidth.Focus();
                txtExWidth.SelectAll();
                return;
            }
            if (!DataValidate.IsDecimal(txtExHeight.Text.Trim()) || Convert.ToDecimal(txtExHeight.Text.Trim()) < 20m)
            {
                MessageBox.Show("请填写脖颈高度", "提示信息");
                txtExHeight.Focus();
                txtExHeight.SelectAll();
                return;
            }
            //ANSUL
            if (cobANSUL.SelectedIndex == -1)
            {
                MessageBox.Show("是否带ANSUL", "提示信息");
                cobANSUL.Focus();
                return;
            }

            if (cobMARVEL.SelectedIndex == -1)
            {
                MessageBox.Show("是否带MARVEL", "提示信息");
                cobMARVEL.Focus();
                return;
            }
            if (cobANSUL.SelectedIndex == 0)
            {
                if (cobANSide.SelectedIndex == -1)
                {
                    MessageBox.Show("请选择ANSUL侧喷位置", "提示信息");
                    cobANSide.Focus();
                    return;
                }
            }
            //UV灯及水洗挡板配置
            if (cobUVType.SelectedIndex == -1)
            {
                MessageBox.Show("请选择UV灯类型", "提示信息");
                cobUVType.Focus();
                return;
            }
            if (cobSensorNo.SelectedIndex == -1)
            {
                MessageBox.Show("请选择W水洗挡板磁感应数量", "提示信息");
                cobUVType.Focus();
                return;
            }
            if (cobSensorNo.SelectedIndex > 0 && (!DataValidate.IsDecimal(txtSensorDis1.Text.Trim()) || Convert.ToDecimal(txtSensorDis1.Text.Trim()) < 10m))
            {
                MessageBox.Show("请认真检查右边W水洗挡板距离烟罩右端面的距离", "提示信息");
                txtSensorDis1.Focus();
                txtSensorDis1.SelectAll();
                return;
            }
            if (cobSensorNo.SelectedIndex > 1 && (!DataValidate.IsDecimal(txtSensorDis2.Text.Trim()) || Convert.ToDecimal(txtSensorDis2.Text.Trim()) < 10m))
            {
                MessageBox.Show("请认真检查W水洗挡板中心间距", "提示信息");
                txtSensorDis2.Focus();
                txtSensorDis2.SelectAll();
                return;
            }
            //其他配置
            if (cobSSPType.SelectedIndex == -1)
            {
                MessageBox.Show("请选择SSP灯板类型", "提示信息");
                cobSSPType.Focus();
                return;
            }
            if (cobJapan.SelectedIndex == -1)
            {
                MessageBox.Show("请选择是否为日本项目", "提示信息");
                cobJapan.Focus();
                return;
            }
            //灯具类型
            if (cobLightType.SelectedIndex == -1)
            {
                MessageBox.Show("请选择灯具类型", "提示信息");
                cobLightType.Focus();
                return;
            }
            //排水槽位置
            if (cobDPSide.SelectedIndex == -1)
            {
                MessageBox.Show("请选择排水槽位置", "提示信息");
                cobDPSide.Focus();
                return;
            }
            //油网
            if (cobFCSide.SelectedIndex == -1)
            {
                MessageBox.Show("请选择油网侧板", "提示信息");
                cobFCSide.Focus();
                return;
            }
            if ((cobFCSide.SelectedIndex == 0 || cobFCSide.SelectedIndex == 2) && (!DataValidate.IsDecimal(txtFCSideLeft.Text.Trim()) || Convert.ToDecimal(txtFCSideLeft.Text.Trim()) < 10m))
            {
                MessageBox.Show("请认真检查左油网侧板长度", "提示信息");//当脖颈大于2时需要填写脖颈间距
                txtFCSideLeft.Focus();
                txtFCSideLeft.SelectAll();
                return;
            }
            if ((cobFCSide.SelectedIndex == 1 || cobFCSide.SelectedIndex == 2) && (!DataValidate.IsDecimal(txtFCSideRight.Text.Trim()) || Convert.ToDecimal(txtFCSideRight.Text.Trim()) < 10m))
            {
                MessageBox.Show("请认真检查右油网侧板长度", "提示信息");//当脖颈大于2时需要填写脖颈间距
                txtFCSideRight.Focus();
                txtFCSideRight.SelectAll();
                return;
            }

            #endregion
            //封装对象
            UCWDB800 objUCWDB800 = new UCWDB800()
            {
                UCWDB800Id = Convert.ToInt32(pbModelImage.Tag),
                ANSUL      = cobANSUL.Text,
                ANSide     = cobANSide.Text.Trim().Length == 0 ? "NO" : cobANSide.Text,
                MARVEL     = cobMARVEL.Text,
                SSPType    = cobSSPType.Text,
                Japan      = cobJapan.Text,
                Gutter     = cobGutter.Text,
                FCSide     = cobFCSide.Text,
                FCBlindNo  = Convert.ToInt32(cobFCBlindNo.Text.Trim()),
                SidePanel  = cobSidePanel.Text,
                LightType  = cobLightType.Text,
                DPSide     = cobDPSide.Text,
                UVType     = cobUVType.Text,
                SensorNo   = Convert.ToInt32(cobSensorNo.Text.Trim()),

                Length      = Convert.ToDecimal(txtLength.Text.Trim()),
                ExRightDis  = Convert.ToDecimal(txtExRightDis.Text.Trim()),
                ExLength    = Convert.ToDecimal(txtExLength.Text.Trim()),
                ExWidth     = Convert.ToDecimal(txtExWidth.Text.Trim()),
                ExHeight    = Convert.ToDecimal(txtExHeight.Text.Trim()),
                GutterWidth = Convert.ToDecimal(txtGutterWidth.Text.Trim()),
                FCSideLeft  = Convert.ToDecimal(txtFCSideLeft.Text.Trim()),
                FCSideRight = Convert.ToDecimal(txtFCSideRight.Text.Trim()),
                SensorDis1  = Convert.ToDecimal(txtSensorDis1.Text.Trim()),
                SensorDis2  = Convert.ToDecimal(txtSensorDis2.Text.Trim())
            };
            //提交修改
            try
            {
                if (objUCWDB800Service.EditModel(objUCWDB800) == 1)
                {
                    MessageBox.Show("制图数据修改成功", "提示信息");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }