private void btnFindProduct_Click(object sender, EventArgs e)
        {
            FormProductType form = new FormProductType();

            if (dataGridView1.Rows.Count > 0)
            {
                List <View_P_ProductInfo> list = new List <View_P_ProductInfo>();

                string[] productType = txtProductType.Text.Split(',');

                foreach (string item in productType)
                {
                    View_P_ProductInfo product = new View_P_ProductInfo();

                    product.产品类型编码 = item;
                    list.Add(product);
                }

                form.SelectedProduct = list;
            }

            string productStr = "";

            if (form.ShowDialog() == DialogResult.OK)
            {
                List <View_P_ProductInfo> productList = form.SelectedProduct;
                m_productInfo = productList;

                if (form.SelectedProduct.Count != form.ProductCount)
                {
                    foreach (View_P_ProductInfo item in productList)
                    {
                        productStr += item.产品类型编码 + ",";
                    }

                    productStr = productStr.Substring(0, productStr.Length - 1);
                }
                else
                {
                    productStr = "全部";
                }
            }

            txtProductType.Text = productStr;
        }
예제 #2
0
        /// <summary>
        /// 点击选择按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSelectField_Click(object sender, EventArgs e)
        {
            int index = 0;

            m_selectedProduct = new List <View_P_ProductInfo>();

            foreach (DataGridViewRow item in dataGridView1.Rows)
            {
                if ((bool)item.Cells[0].Value)
                {
                    View_P_ProductInfo user = (from r in m_lstAllProduct
                                               where r.产品类型编码 == item.Cells[2].Value.ToString()
                                               select r).Single();
                    m_selectedProduct.Add(user);
                }

                index++;
            }

            this.DialogResult = DialogResult.OK;
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cmbSourceProductType.SelectedIndex == -1)
            {
                cmbSourceProductType.Focus();
                MessageDialog.ShowErrorMessage("产品类型不允许为空");
                return;
            }

            if (txtTargetProductType.Text.Trim() == "")
            {
                txtTargetProductType.Focus();
                MessageDialog.ShowErrorMessage("产品类型不允许为空");
                return;
            }

            if (txtTargetProductType.Text.Contains(cmbSourceProductType.Text))
            {
                txtTargetProductType.Focus();
                MessageDialog.ShowErrorMessage("源产品类型不允许和目标产品类型相同");
                return;
            }

            if (m_copyMode == CopyModeEnum.制分总成下属零件信息 && cmbParentName.SelectedIndex == -1)
            {
                cmbParentName.Focus();
                MessageDialog.ShowErrorMessage("总成名称不允许为空");
                return;
            }

            m_sourceProductInfo = m_productInfo.First(p => p.产品类型编码 == cmbSourceProductType.Text);
            m_targetProductInfo = m_productInfo.First(p => p.产品类型编码 == txtTargetProductType.Text);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cmbSourceProductType.SelectedIndex == -1)
            {
                cmbSourceProductType.Focus();
                MessageDialog.ShowErrorMessage("产品类型不允许为空");
                return;
            }

            if (cmbTargetProductType.SelectedIndex == -1)
            {
                cmbTargetProductType.Focus();
                MessageDialog.ShowErrorMessage("产品类型不允许为空");
                return;
            }

            if (cmbSourceProductType.Text == cmbTargetProductType.Text)
            {
                cmbTargetProductType.Focus();
                MessageDialog.ShowErrorMessage("源产品类型不允许和目标产品类型相同");
                return;
            }

            if (m_copyMode == CopyModeEnum.制指定工位装配顺序 && cmbWorkbench.SelectedIndex == -1)
            {
                cmbWorkbench.Focus();
                MessageDialog.ShowErrorMessage("总成名称不允许为空");
                return;
            }

            m_sourceProductInfo = m_productInfo.First(p => p.产品类型编码 == cmbSourceProductType.Text);
            m_targetProductInfo = m_productInfo.First(p => p.产品类型编码 == cmbTargetProductType.Text);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #5
0
        /// <summary>
        /// 复制指定版本的装配BOM的指定分总成信息到目标版本
        /// </summary>
        /// <param name="surEdition">源装配BOM版本号</param>
        /// <param name="tarEdition">目标装配BOM版本号</param>
        /// <param name="tarParentName">分总成名称</param>
        /// <param name="error">操作错误时返回的错误信息</param>
        /// <returns>复制成功返回True,复制失败返回False</returns>
        public bool CopyBomData(string surEdition, string tarEdition, string tarParentName, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                bool isExist = (from r in ctx.P_AssemblingBom
                                where r.ProductCode == tarEdition && r.ParentName == tarParentName
                                select r).Count() > 0;

                if (isExist)
                {
                    error = string.Format("{0} 的 {1} 已经存在下属零件信息,请删除 {0} {1} 下的所有原有子零件后再进行此操作",
                                          tarEdition, tarParentName);
                    return(false);
                }

                var result2 = from r in ctx.P_AssemblingBom
                              where r.ProductCode == tarEdition && r.PartName == tarParentName
                              select r;

                if (result2.Count() == 0)
                {
                    error = string.Format("{0} 中不存在 {1} 零件,无法为不存在的 {1} 添加子零件", tarEdition, tarParentName);
                    return(false);
                }
                else
                {
                    if (!result2.Single().AssemblyFlag)
                    {
                        error = string.Format("{0} 中的 {1} 零件被设置为不是分总成,无法为不是分总成的 {1} 添加子零件",
                                              tarEdition, tarParentName);
                        return(false);
                    }
                }

                isExist = (from r in ctx.P_AssemblingBom
                           where r.ProductCode == surEdition && r.ParentName == tarParentName
                           select r).Count() > 0;

                if (!isExist)
                {
                    error = string.Format("找不到{0}的零件信息", surEdition);
                    return(false);
                }

                View_P_ProductInfo targetProductInfo = (from r in ctx.View_P_ProductInfo
                                                        where r.产品类型编码 == tarEdition
                                                        select r).First();

                CopyChildPart(ctx, surEdition, targetProductInfo, tarParentName);

                ctx.SubmitChanges();
                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
예제 #6
0
        /// <summary>
        /// 复制子零件
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="surEdition">源装配BOM版本号</param>
        /// <param name="tarEdition">目标装配BOM产品信息</param>
        /// <param name="parentName">分总成名称</param>
        private void CopyChildPart(DepotManagementDataContext ctx, string surEdition, View_P_ProductInfo tarEdition, string parentName)
        {
            var result = from r in ctx.P_AssemblingBom
                         where r.ProductCode == surEdition && r.ParentName == parentName
                         select r;

            DateTime serverTime = ServerTime.Time;

            foreach (var item in result)
            {
                P_AssemblingBom info = new P_AssemblingBom();

                info.ProductCode        = tarEdition.产品类型编码;
                info.ParentCode         = item.ParentCode;
                info.ParentName         = item.ParentName;
                info.PartCode           = item.PartCode;
                info.PartName           = item.PartName;
                info.Spec               = item.Spec;
                info.IsMaterialShortage = item.IsMaterialShortage;
                info.IsAdaptingPart     = item.IsAdaptingPart;
                info.NeedToClean        = item.NeedToClean;
                info.AssemblyFlag       = item.AssemblyFlag;
                info.RasterProofing     = item.RasterProofing;
                info.Date               = serverTime;
                info.Remarks            = item.Remarks;
                info.UserCode           = GlobalObject.BasicInfo.LoginID;
                info.Workbench          = item.Workbench;
                info.FittingCounts      = item.FittingCounts;
                info.OrderNo            = item.OrderNo;

                if (info.ParentCode == surEdition)
                {
                    info.ParentCode = tarEdition.产品类型编码;
                    info.ParentName = tarEdition.产品类型名称;
                }
                else if (info.PartCode == surEdition)
                {
                    info.PartCode = tarEdition.产品类型编码;
                    info.PartName = tarEdition.产品类型名称;
                }

                ctx.P_AssemblingBom.InsertOnSubmit(info);

                if (item.AssemblyFlag)
                {
                    var result2 = from r in ctx.P_AssemblingBom
                                  where r.ProductCode == surEdition && r.ParentName == item.PartName
                                  select r;

                    if (result2.Count() > 0)
                    {
                        CopyChildPart(ctx, surEdition, tarEdition, item.PartName);
                    }
                }
            }
        }
예제 #7
0
        /// <summary>
        /// 复制指定版本的装配BOM信息到目标版本
        /// </summary>
        /// <param name="surEdition">源装配BOM版本号</param>
        /// <param name="tarEdition">目标装配BOM版本号</param>
        /// <param name="error">操作错误时返回的错误信息</param>
        /// <returns>复制成功返回True,复制失败返回False</returns>
        public bool CopyBomData(string surEdition, string tarEdition, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                bool blIsExist = (from r in dataContxt.P_AssemblingBom
                                  where r.ProductCode == tarEdition
                                  select r).Count() > 0;

                if (blIsExist)
                {
                    error = string.Format("{0}的零件信息已经存在,不允许再次复制", tarEdition);
                    return(false);
                }

                var result = from r in dataContxt.P_AssemblingBom
                             where r.ProductCode == surEdition select r;

                if (result.Count() == 0)
                {
                    error = string.Format("找不到{0}的零件信息", surEdition);
                    return(false);
                }

                View_P_ProductInfo lnqTargetProductInfo = (from r in dataContxt.View_P_ProductInfo
                                                           where r.产品类型编码 == tarEdition
                                                           select r).First();

                DateTime dtServerTime = ServerTime.Time;

                foreach (var item in result)
                {
                    P_AssemblingBom lnqInfo = new P_AssemblingBom();

                    lnqInfo.ProductCode        = tarEdition;
                    lnqInfo.ParentCode         = item.ParentCode;
                    lnqInfo.ParentName         = item.ParentName;
                    lnqInfo.PartCode           = item.PartCode;
                    lnqInfo.PartName           = item.PartName;
                    lnqInfo.Spec               = item.Spec;
                    lnqInfo.IsMaterialShortage = item.IsMaterialShortage;
                    lnqInfo.IsAdaptingPart     = item.IsAdaptingPart;
                    lnqInfo.NeedToClean        = item.NeedToClean;
                    lnqInfo.AssemblyFlag       = item.AssemblyFlag;
                    lnqInfo.RasterProofing     = item.RasterProofing;
                    lnqInfo.Date               = dtServerTime;
                    lnqInfo.Remarks            = item.Remarks;
                    lnqInfo.UserCode           = GlobalObject.BasicInfo.LoginID;
                    lnqInfo.Workbench          = item.Workbench;
                    lnqInfo.FittingCounts      = item.FittingCounts;
                    lnqInfo.OrderNo            = item.OrderNo;

                    if (lnqInfo.ParentCode == surEdition)
                    {
                        lnqInfo.ParentCode = tarEdition;
                        lnqInfo.ParentName = lnqTargetProductInfo.产品类型名称;
                    }
                    else if (lnqInfo.PartCode == surEdition)
                    {
                        lnqInfo.PartCode = tarEdition;
                        lnqInfo.PartName = lnqTargetProductInfo.产品类型名称;
                    }

                    dataContxt.P_AssemblingBom.InsertOnSubmit(lnqInfo);
                }

                dataContxt.SubmitChanges();
                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }