Exemplo n.º 1
0
        //新增图号
        private void AddDrawing()
        {
            #region 【1】(新增)封装属性并保存到模型中
            //1-封装图号对象
            DrawingModel objDrawing = new DrawingModel()
            {
                DrawingClassId   = this.cboDrawingClass.SelectedValue == null ? null : this.cboDrawingClass.SelectedValue.ToString(),
                DrawingCode      = this.txtDrawingCode.Text.Trim(),
                MaterialName     = this.txtMaterialName.Text.Trim(),
                MaterialSpec     = this.txtMaterialSpec.Text.Trim(),
                Unit             = this.cboUnit.SelectedValue == null ? null : this.cboUnit.SelectedValue.ToString(),
                PurchaseTypeId   = this.cboPurchaseType.SelectedValue == null ? null : this.cboPurchaseType.SelectedValue.ToString(),
                SelectionTypeId  = this.cboSelectionType.SelectedValue == null ? null : this.cboSelectionType.SelectedValue.ToString(),
                HeatTreatment    = this.txtHeatTreatment.Text.Trim(),
                SurfaceTreatment = this.txtSurfaceTreatment.Text.Trim(),
                Revision         = 1,
                DrawingStatusId  = 0,//申请状态-0
                Weight           = ConvertEx.ToFloat(this.txtWeight.Text.Trim()).ToString("F2"),
                Brand            = this.txtBrand.Text.Trim(),
                ReMark           = this.txtReMark.Text.Trim(),
                DocIdModel       = ConvertEx.ToInt(Globals.FileID),
                CreateFrom       = "来自SW插件",
                CreateId         = Globals.DEF_CreateId,
                CreateUser       = Globals.DEF_CreateUser,
                CreateDate       = objDrawingService.GetDBServerTime(),
                CreateInfo       = Globals.DEF_CreateInfo
            };
            //2-无论数据库是否保存,都将填写的内容更新到本模型属性中
            swAppHelper.UpdateProperty(objDrawing);
            //Msg.ShowInformation("文件属性已更新并保存!");
            Globals.CurrentDrawing = objDrawing;//给全局变量赋值
            #endregion

            #region 【2】(新增)将数据提交到数据库
            try
            {
                if (objDrawingService.AddDrawing(objDrawing))
                {
                    this.DialogResult = DialogResult.OK;
                    Msg.ShowInformation("添加成功,请保存文件!");
                    //只允许提交一次
                    this.btnAddMaterial.Enabled = false;
                }
                else
                {
                    Msg.ShowError("添加失败!");
                }
            }
            catch (Exception ex)
            {
                Msg.ShowError(ex.Message);
            }
            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// 修改图号
        /// </summary>
        /// <param name="objDrawing"></param>
        /// <returns></returns>
        public bool ModifyMaterial(MaterialModel objMaterial)
        {
            SQLHelper.connString = Globals.connStrGroupDBName;
            //string sql = "update code_Drawing set DrawingClassId=@DrawingClassId, DrawingCode=@DrawingCode, MaterialName=@MaterialName, MaterialSpec=@MaterialSpec, Weight=@Weight, Unit=@Unit, HeatTreatment=@HeatTreatment, SurfaceTreatment=@SurfaceTreatment, Brand=@Brand, PurchaseTypeId=@PurchaseTypeId, SelectionTypeId=@SelectionTypeId, DrawingStatusId=@DrawingStatusId, Revision=@Revision, DocIdModel=@DocIdModel, ReMark=@ReMark, UpdateId=@UpdateId, UpdateUser=@UpdateUser, UpdateDate=@UpdateDate, UpdateInfo=@UpdateInfo where DrawingId=@DrawingId";
            string sql = "update code_Material set MaterialName=@MaterialName, MaterialSpec=@MaterialSpec, MaterialType=@MaterialType, Mquality=@Mquality, Weight=@Weight, Unit=@Unit, ImportanceGrade=@ImportanceGrade, DraftFeatureId=@DraftFeatureId, MachiningPropertyId=@MachiningPropertyId, PaintingColor=@PaintingColor, HeatTreatment=@HeatTreatment, SurfaceTreatment=@SurfaceTreatment, BrandId=@BrandId, ReMark=@ReMark, UpdateId=@UpdateId, UpdateUser=@UpdateUser, UpdateDate=@UpdateDate, UpdateInfo=@UpdateInfo where MaterialId=@MaterialId";

            SqlParameter[] param = new SqlParameter[]
            {
                //只封装一部分主要的参数
                new SqlParameter("@MaterialId", objMaterial.MaterialId),
                //new SqlParameter("@MaterialClassId",objMaterial.MaterialClassId),
                //new SqlParameter("@MaterialCode",objMaterial.MaterialCode),
                //new SqlParameter("@FactoryCode",objMaterial.FactoryCode),
                //new SqlParameter("@IsPublic",objMaterial.IsPublic),
                //new SqlParameter("@MaterialCategoryId",objMaterial.MaterialCategoryId),
                //new SqlParameter("@DrawingCode",objMaterial.DrawingCode),
                new SqlParameter("@MaterialName", objMaterial.MaterialName),
                new SqlParameter("@MaterialSpec", objMaterial.MaterialSpec),
                new SqlParameter("@MaterialType", objMaterial.MaterialType),
                new SqlParameter("@Mquality", objMaterial.Mquality),
                new SqlParameter("@Weight", objMaterial.Weight),
                new SqlParameter("@Unit", objMaterial.Unit),
                new SqlParameter("@ImportanceGrade", ConvertEx.SqlNull(objMaterial.ImportanceGrade)),
                new SqlParameter("@DraftFeatureId", ConvertEx.SqlNull(objMaterial.DraftFeatureId)),
                new SqlParameter("@MachiningPropertyId", ConvertEx.SqlNull(objMaterial.MachiningPropertyId)),
                new SqlParameter("@PaintingColor", ConvertEx.SqlNull(objMaterial.PaintingColor)),
                new SqlParameter("@HeatTreatment", objMaterial.HeatTreatment),
                new SqlParameter("@SurfaceTreatment", objMaterial.SurfaceTreatment),
                new SqlParameter("@BrandId", ConvertEx.SqlNull(objMaterial.BrandId)),
                //new SqlParameter("@StatusId",objMaterial.StatusId),
                //new SqlParameter("@Revision",objMaterial.Revision),
                //new SqlParameter("@DocIdModel",objMaterial.DocIdModel),
                new SqlParameter("@ReMark", objMaterial.ReMark),
                new SqlParameter("@UpdateId", objMaterial.UpdateId),
                new SqlParameter("@UpdateUser", objMaterial.UpdateUser),
                new SqlParameter("@UpdateDate", objMaterial.UpdateDate),
                new SqlParameter("@UpdateInfo", objMaterial.UpdateInfo)
            };
            int result = SQLHelper.Update(sql, param, false);

            return(result != 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增物料编码
        /// </summary>
        /// <param name="objMaterial"></param>
        /// <returns></returns>
        public bool AddMaterial(MaterialModel objMaterial)
        {
            SQLHelper.connString = Globals.connStrGroupDBName;
            string sql = "insert into code_Material(MaterialClassId, MaterialCode, FactoryCode, IsPublic, MaterialCategoryId, DrawingCode, MaterialName, MaterialSpec, MaterialType, Mquality, Weight, Unit, ImportanceGrade, DraftFeatureId, MachiningPropertyId, PaintingColor, HeatTreatment, SurfaceTreatment, BrandId, StatusId, Revision, DocIdModel, ReMark, CreateFrom, CreateId, CreateUser, CreateDate, CreateInfo) values(@MaterialClassId, @MaterialCode, @FactoryCode, @IsPublic, @MaterialCategoryId, @DrawingCode, @MaterialName, @MaterialSpec, @MaterialType, @Mquality, @Weight, @Unit, @ImportanceGrade, @DraftFeatureId, @MachiningPropertyId, @PaintingColor, @HeatTreatment, @SurfaceTreatment, @BrandId, @StatusId, @Revision, @DocIdModel, @ReMark, @CreateFrom, @CreateId, @CreateUser, @CreateDate, @CreateInfo)";

            SqlParameter[] param = new SqlParameter[]
            {
                //只封装一部分主要的参数
                new SqlParameter("@MaterialClassId", objMaterial.MaterialClassId),
                new SqlParameter("@MaterialCode", objMaterial.MaterialCode),
                new SqlParameter("@FactoryCode", objMaterial.FactoryCode),
                new SqlParameter("@IsPublic", objMaterial.IsPublic),
                new SqlParameter("@MaterialCategoryId", objMaterial.MaterialCategoryId),
                new SqlParameter("@DrawingCode", objMaterial.DrawingCode),
                new SqlParameter("@MaterialName", objMaterial.MaterialName),
                new SqlParameter("@MaterialSpec", objMaterial.MaterialSpec),
                new SqlParameter("@MaterialType", objMaterial.MaterialType),
                new SqlParameter("@Mquality", objMaterial.Mquality),
                new SqlParameter("@Weight", objMaterial.Weight),
                new SqlParameter("@Unit", objMaterial.Unit),
                new SqlParameter("@ImportanceGrade", ConvertEx.SqlNull(objMaterial.ImportanceGrade)),
                new SqlParameter("@DraftFeatureId", ConvertEx.SqlNull(objMaterial.DraftFeatureId)),
                new SqlParameter("@MachiningPropertyId", ConvertEx.SqlNull(objMaterial.MachiningPropertyId)),
                new SqlParameter("@PaintingColor", ConvertEx.SqlNull(objMaterial.PaintingColor)),
                new SqlParameter("@HeatTreatment", objMaterial.HeatTreatment),
                new SqlParameter("@SurfaceTreatment", objMaterial.SurfaceTreatment),
                new SqlParameter("@BrandId", ConvertEx.SqlNull(objMaterial.BrandId)),
                new SqlParameter("@StatusId", objMaterial.StatusId),
                new SqlParameter("@Revision", objMaterial.Revision),
                new SqlParameter("@DocIdModel", objMaterial.DocIdModel),
                new SqlParameter("@ReMark", objMaterial.ReMark),
                new SqlParameter("@CreateFrom", objMaterial.CreateFrom),
                new SqlParameter("@CreateId", objMaterial.CreateId),
                new SqlParameter("@CreateUser", objMaterial.CreateUser),
                new SqlParameter("@CreateDate", objMaterial.CreateDate),
                new SqlParameter("@CreateInfo", objMaterial.CreateInfo)
            };
            int result = SQLHelper.Update(sql, param, false);

            return(result != 0);
        }
Exemplo n.º 4
0
        //选择正确的子节点,并给全局变量赋值
        private void tsbConfirm_Click(object sender, EventArgs e)
        {
            //未选中任何节点,提示
            if (tvMaterialClass.SelectedNode == null)
            {
                Msg.ShowError("未选中任何节点,无法操作!");
                return;
            }
            //选中节点的ID【MaterialClassId】
            string selectedNodeId = tvMaterialClass.SelectedNode.Tag.ToString().Split('_')[0];

            //选中最后一层,不允许添加节点
            if (selectedNodeId.Length < 4)//最后一层,位数为4位,如:1001
            {
                Msg.ShowError("请选择最后一级节点!");
                return;
            }
            //从数据库获取选中节点的完整信息
            DataRow       dr          = objMaterialService.GetMaterialClassById(selectedNodeId);
            MaterialModel objMaterial = new MaterialModel()
            {
                MaterialClassId = selectedNodeId,
                IsPublic        = ConvertEx.ToBoolean(dr["IsPublic"]),
                FactoryCode     = ConvertEx.ToString(dr["FactoryCode"])
            };

            //Globals.CurrentMaterial.MaterialClassId = ConvertEx.ToInt(selectedNodeId);
            //Globals.CurrentMaterial.IsPublic = ConvertEx.ToBoolean(dr["IsPublic"]);
            //Globals.CurrentMaterial.FactoryCode = ConvertEx.ToString(dr["FactoryCode"]);
            if (selectedNodeId.Length == 4)
            {
                Globals.CurrentMaterial = objMaterial;
                this.DialogResult       = DialogResult.Yes;
            }
            else
            {
                this.DialogResult = DialogResult.No;
            }
            //Msg.ShowInformation(objMaterial.MaterialClassId.ToString());
        }
Exemplo n.º 5
0
        //修改图号
        private void ModifyDrawing(string drawingId)
        {
            //询问是否修改现有图号信息
            if (Msg.AskQuestion("该图号信息已经存在,需要修改吗?"))
            {
                #region 【1】(修改)封装属性并保存到模型中
                //1-封装图号对象
                DrawingModel objDrawing = new DrawingModel()
                {
                    DrawingId        = drawingId,
                    DrawingClassId   = this.cboDrawingClass.SelectedValue == null ? null : this.cboDrawingClass.SelectedValue.ToString(),
                    DrawingCode      = this.txtDrawingCode.Text.Trim(),
                    MaterialName     = this.txtMaterialName.Text.Trim(),
                    MaterialSpec     = this.txtMaterialSpec.Text.Trim(),
                    Unit             = this.cboUnit.SelectedValue == null ? null : this.cboUnit.SelectedValue.ToString(),
                    PurchaseTypeId   = this.cboPurchaseType.SelectedValue == null ? null : this.cboPurchaseType.SelectedValue.ToString(),
                    SelectionTypeId  = this.cboSelectionType.SelectedValue == null ? null : this.cboSelectionType.SelectedValue.ToString(),
                    HeatTreatment    = this.txtHeatTreatment.Text.Trim(),
                    SurfaceTreatment = this.txtSurfaceTreatment.Text.Trim(),
                    Weight           = ConvertEx.ToFloat(this.txtWeight.Text.Trim()).ToString("F2"),
                    Brand            = this.txtBrand.Text.Trim(),
                    ReMark           = this.txtReMark.Text.Trim(),
                    //修改时增加更改人信息
                    UpdateId   = Globals.DEF_CreateId,
                    UpdateUser = Globals.DEF_CreateUser,
                    UpdateDate = objDrawingService.GetDBServerTime(),
                    UpdateInfo = Globals.DEF_CreateInfo
                                 //修改时不改变原来的信息(版本、状态、文件ID等)
                                 //Revision = 1,
                                 //DrawingStatusId = 0,//申请状态-0
                                 //DocIdModel = ConvertEx.ToInt(Globals.FileID),
                                 //CreateFrom = "来自SW插件",
                                 //CreateId = Globals.DEF_CreateId,
                                 //CreateUser = Globals.DEF_CreateUser,
                                 //CreateDate = objDrawingService.GetDBServerTime(),
                                 //CreateInfo = Globals.DEF_CreateInfo
                };
                //2-无论数据库是否保存,都将填写的内容更新到本模型属性中
                swAppHelper.UpdateProperty(objDrawing);
                //Msg.ShowInformation("文件属性已更新并保存!");
                Globals.CurrentDrawing = objDrawing;//给全局变量赋值
                #endregion

                #region 【2】(修改)将数据提交到数据库
                try
                {
                    if (objDrawingService.ModifyMaterial(objDrawing))
                    {
                        this.DialogResult = DialogResult.OK;
                        Msg.ShowInformation("修改成功,请保存文件!");
                        //只允许提交一次
                        this.btnAddMaterial.Enabled = false;
                    }
                    else
                    {
                        Msg.ShowError("修改失败!");
                    }
                }
                catch (Exception ex)
                {
                    Msg.ShowError(ex.Message);
                }
                #endregion
            }
            else
            {
                return;
            }
        }
Exemplo n.º 6
0
        //新增图号(物料编码)
        private void AddDrawing()
        {
            #region 【1】(新增)封装属性并保存到模型中
            //1-封装图号对象
            MaterialModel objMaterial = new MaterialModel()
            {
                DocIdModel         = ConvertEx.ToInt(Globals.FileID),
                MaterialId         = this.txtMaterialId.Text.Trim(),
                IsPublic           = ConvertEx.ToBoolean(this.txtIsPublic.Text.Trim()),
                MaterialCode       = this.txtMaterialCode.Text.Trim(),
                FactoryCode        = this.txtFactoryCode.Text.Trim(),
                MaterialClassId    = this.txtMaterialClassId.Text.Trim(),
                MaterialCategoryId = this.cboMaterialCategoryId.SelectedValue.ToString(),
                DrawingCode        = this.txtDrawingCode.Text.Trim(),
                MaterialName       = this.txtMaterialName.Text.Trim(),
                MaterialSpec       = this.txtMaterialSpec.Text.Trim(),
                MaterialType       = this.txtMaterialType.Text.Trim(),
                Unit                = this.cboUnit.SelectedValue.ToString(),
                Mquality            = this.txtMquality.Text.Trim(),
                Weight              = ConvertEx.ToFloat(this.txtWeight.Text.Trim()).ToString("F2"),
                MachiningPropertyId = this.cboMachiningProperty.SelectedValue.ToString(),
                PaintingColor       = this.cboPaintingColor.SelectedValue == null ? null : this.cboPaintingColor.SelectedValue.ToString(),
                BrandId             = this.cboBrandId.SelectedValue == null ? null : this.cboBrandId.SelectedValue.ToString(),
                ImportanceGrade     = this.cboImportanceGrade.Text,
                DraftFeatureId      = this.cboDraftFeatureId.SelectedValue == null ? null : this.cboDraftFeatureId.SelectedValue.ToString(),
                HeatTreatment       = this.txtHeatTreatment.Text.Trim(),
                SurfaceTreatment    = this.txtSurfaceTreatment.Text.Trim(),
                ReMark              = this.txtReMark.Text.Trim(),
                Revision            = 1,
                StatusId            = 0,//申请状态-0
                CreateFrom          = "来自SW插件",
                CreateId            = Globals.DEF_CreateId,
                CreateUser          = Globals.DEF_CreateUser,
                CreateDate          = objDrawingService.GetDBServerTime(),
                CreateInfo          = Globals.DEF_CreateInfo
            };
            //★★保存之前从数据库获取最新流水码★★
            objMaterial.MaterialCode = objMaterialService.GetNewMaterialCode(objMaterial.MaterialClassId);
            //2-无论数据库是否保存,都将填写的内容更新到本模型属性中
            swAppHelper.UpdateProperty(objMaterial);
            //Msg.ShowInformation("文件属性已更新并保存!");
            Globals.CurrentMaterial = objMaterial;//给全局变量赋值
            #endregion

            #region 【2】(新增)将数据提交到数据库
            try
            {
                if (objMaterialService.AddMaterial(objMaterial))
                {
                    this.DialogResult = DialogResult.OK;
                    Msg.ShowInformation("添加成功,请保存文件!");
                    //只允许提交一次
                    this.tsbAddMaterial.Enabled = false;
                }
                else
                {
                    Msg.ShowError("添加失败!");
                }
            }
            catch (Exception ex)
            {
                Msg.ShowError(ex.Message);
            }
            #endregion
        }