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

            sqlBuilder.Append("Update UCJFCCOMBIDXF set Quantity=@Quantity where UCJFCCOMBIDXFId=@UCJFCCOMBIDXFId");
            //定义参数数组
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@Quantity", objModel.Quantity),
                new SqlParameter("@UCJFCCOMBIDXFId", objModel.UCJFCCOMBIDXFId)
            };
            try
            {
                return(SQLHelper.Update(sqlBuilder.ToString(), param));
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库操作出现异常:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public FrmUCJFCCOMBIDXF(Drawing drawing, ModuleTree tree) : this()
        {
            objUCJFCCOMBIDXF = (UCJFCCOMBIDXF)objUCJFCCOMBIDXFService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());
            if (objUCJFCCOMBIDXF == 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 #3
0
        public IModel GetModelByWhereSql(string whereSql)
        {
            string sql =
                "select UCJFCCOMBIDXFId,ModuleTreeId,Quantity from UCJFCCOMBIDXF";

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

            if (objReader.Read())
            {
                objModel = new UCJFCCOMBIDXF()
                {
                    UCJFCCOMBIDXFId = Convert.ToInt32(objReader["UCJFCCOMBIDXFId"]),
                    ModuleTreeId    = Convert.ToInt32(objReader["ModuleTreeId"]),
                    //最好不要用=null去判断,提示类型转换错误
                    Quantity = objReader["Quantity"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["Quantity"]),
                };
            }
            objReader.Close();
            return(objModel);
        }
        /// <summary>
        /// 修改参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEditData_Click(object sender, EventArgs e)
        {
            #region 数据验证
            //必填项目
            if (pbModelImage.Tag.ToString().Length == 0)
            {
                return;
            }
            if (!DataValidate.IsInteger(txtQuantity.Text.Trim()))
            {
                MessageBox.Show("请认真检查数量是否填错", "提示信息");
                txtQuantity.Focus();
                txtQuantity.SelectAll();
                return;
            }


            #endregion
            //封装对象
            UCJFCCOMBIDXF objUCJFCCOMBIDXF = new UCJFCCOMBIDXF()
            {
                UCJFCCOMBIDXFId = Convert.ToInt32(pbModelImage.Tag),
                Quantity        = Convert.ToInt32(txtQuantity.Text)
            };
            //提交修改
            try
            {
                if (objUCJFCCOMBIDXFService.EditModel(objUCJFCCOMBIDXF) == 1)
                {
                    MessageBox.Show("制图数据修改成功", "提示信息");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        public void AutoDrawing(SldWorks swApp, ModuleTree tree, string projectPath)
        {
            //创建下料图文件夹,默认在D盘MyProjects目录下(先判断文件夹是否存在)
            string dxfPath = projectPath + @"\DXF-CUTLIST";

            if (!Directory.Exists(dxfPath))
            {
                Directory.CreateDirectory(dxfPath);
            }
            //创建dxf图文件夹
            string newPath = dxfPath + @"\" + tree.Item + "-" + tree.Module + @"\";

            if (!Directory.Exists(newPath))
            {
                Directory.CreateDirectory(newPath);
            }
            //拷贝文件,调用通用函数
            if (!CommonFunc.CopyDxfFiles(tree.ModelPath, newPath))
            {
                return;
            }
            //查询参数
            UCJFCCOMBIDXF objUCJFCCOMBIDXF = (UCJFCCOMBIDXF)objUCJFCCOMBIDXFService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());
            //查询标准DxfCutlist,根据item.categoryId查询dxfCutList对象列表
            List <DXFCutList> oldList = objDxfCutListService.GetDXFCutListsByCategoryId(tree.CategoryId.ToString());

            Project objProject = objProjectService.GetProjectByProjectId(tree.ProjectId.ToString());

            #region HoodCutList
            if (objProject.HoodType == "Hood")
            {
                //乘以数量,赋值moduletreeid
                foreach (var item in oldList)
                {
                    hoodCutLists.Add(new HoodCutList()
                    {
                        ModuleTreeId    = objUCJFCCOMBIDXF.ModuleTreeId,
                        PartDescription = item.PartDescription,
                        Length          = item.Length,
                        Width           = item.Width,
                        Thickness       = item.Thickness,
                        Quantity        = item.Quantity * objUCJFCCOMBIDXF.Quantity,//多个UCP
                        Materials       = item.Materials,
                        PartNo          = item.PartNo,
                        UserId          = 1
                    });
                }
                //基于事务hoodCutLists提交SQLServer
                if (hoodCutLists.Count == 0)
                {
                    return;
                }
                try
                {
                    if (objHoodCutListService.ImportCutList(hoodCutLists))
                    {
                        hoodCutLists.Clear();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("UCJFCCOMBIDXF的HoodCutlist导入数据库失败" + ex.Message);
                }
            }
            #endregion


            #region CeilingCutList

            if (objProject.HoodType == "Ceiling")
            {
                //添加SubAssy,获得SubAssyId
                int subAssyId = objSubAssyService.AddSubAssy(new SubAssy()
                {
                    ProjectId   = objProject.ProjectId,
                    SubAssyName = tree.Module
                });
                //乘以数量,赋值moduletreeid
                foreach (var item in oldList)
                {
                    ceilingCutLists.Add(new CeilingCutList()
                    {
                        SubAssyId       = subAssyId,
                        PartDescription = item.PartDescription,
                        Length          = item.Length,
                        Width           = item.Width,
                        Thickness       = item.Thickness,
                        Quantity        = item.Quantity * objUCJFCCOMBIDXF.Quantity,//多个UCP
                        Materials       = item.Materials,
                        PartNo          = item.PartNo,
                        UserId          = 1
                    });
                }
                //基于事务CeilingCutLists提交SQLServer
                if (ceilingCutLists.Count == 0)
                {
                    return;
                }
                try
                {
                    if (objCeilingCutListService.ImportCutList(ceilingCutLists))
                    {
                        ceilingCutLists.Clear();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("UCJFCCOMBIDXF的CeilingCutlist导入数据库失败" + ex.Message);
                }
            }
            #endregion
        }