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

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

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

            if (objReader.Read())
            {
                objModel = new LFUMC150DXF()
                {
                    LFUMC150DXFId = Convert.ToInt32(objReader["LFUMC150DXFId"]),
                    ModuleTreeId  = Convert.ToInt32(objReader["ModuleTreeId"]),
                    //最好不要用=null去判断,提示类型转换错误
                    Quantity = objReader["Quantity"].ToString().Length == 0 ? 0 : Convert.ToInt32(objReader["Quantity"]),
                };
            }
            objReader.Close();
            return(objModel);
        }
예제 #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 (!DataValidate.IsInteger(txtQuantity.Text.Trim()))
            {
                MessageBox.Show("请认真检查数量是否填错", "提示信息");
                txtQuantity.Focus();
                txtQuantity.SelectAll();
                return;
            }


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