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

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

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

            if (objReader.Read())
            {
                objModel = new UCPDXF()
                {
                    UCPDXFId     = Convert.ToInt32(objReader["UCPDXFId"]),
                    ModuleTreeId = Convert.ToInt32(objReader["ModuleTreeId"]),
                    //最好不要用=null去判断,提示类型转换错误
                    Quantity = objReader["Quantity"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["Quantity"]),
                };
            }
            objReader.Close();
            return(objModel);
        }
Exemple #4
0
        /// <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 (cobQuantity.SelectedIndex == -1)
            {
                MessageBox.Show("请选择数量", "提示信息");
                cobQuantity.Focus();
                return;
            }

            #endregion
            //封装对象
            UCPDXF objUCPDXF = new UCPDXF()
            {
                UCPDXFId = Convert.ToInt32(pbModelImage.Tag),
                Quantity = Convert.ToInt32(cobQuantity.Text)
            };
            //提交修改
            try
            {
                if (objUCPDXFService.EditModel(objUCPDXF) == 1)
                {
                    MessageBox.Show("制图数据修改成功", "提示信息");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        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;
            }
            //查询参数
            UCPDXF objUcpDxf = (UCPDXF)objUCPDXFService.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    = objUcpDxf.ModuleTreeId,
                        PartDescription = item.PartDescription,
                        Length          = item.Length,
                        Width           = item.Width,
                        Thickness       = item.Thickness,
                        Quantity        = item.Quantity * objUcpDxf.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("UCPDXF的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 * objUcpDxf.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("UCPDXF的CeilingCutlist导入数据库失败" + ex.Message);
                }
            }
            #endregion
        }