Ejemplo n.º 1
0
        void GetGoodsInfo()
        {
            if (txtCode.Tag == null)
            {
                lbHYDW.Text = "";
                lbKCDW.Text = "";
                return;
            }

            View_F_GoodsPlanCost tempLnq = UniversalFunction.GetGoodsInfo(Convert.ToInt32(txtCode.Tag));

            if (tempLnq == null)
            {
                lbHYDW.Text = "";
                lbKCDW.Text = "";
                return;
            }

            lbHYDW.Text = tempLnq.单位;
            lbKCDW.Text = tempLnq.单位;

            WS_WorkShopStock tempStock =
                m_serverStock.GetStockSingleInfo(CE_WorkShopCode.ZPCJ.ToString(), Convert.ToInt32(txtCode.Tag), txtBatchNo.Text);

            if (tempStock == null)
            {
                lbStockCount.Text = "0";
            }
            else
            {
                lbStockCount.Text = tempStock.StockCount.ToString();
            }
        }
        /// <summary>
        /// 操作明细账(并且操作库存)
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="subsidiary">明细账对象</param>
        public void OperationSubsidiary(DepotManagementDataContext ctx, WS_Subsidiary subsidiary)
        {
            if (!Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启车间管理模块]))
            {
                return;
            }

            Service_Manufacture_WorkShop.IWorkShopProductCode serverProduct =
                Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopProductCode>();

            BASE_SubsidiaryOperationType tempOperationType = UniversalFunction.GetSubsidiaryOperationType(subsidiary.OperationType);

            if (tempOperationType == null)
            {
                throw new Exception("明细账操作类型错误,请重新确认");
            }

            serverProduct.OperatorProductCodeStock(ctx, subsidiary.BillNo,
                                                   subsidiary.GoodsID, subsidiary.OperationType);

            ctx.WS_Subsidiary.InsertOnSubmit(subsidiary);
            WS_WorkShopStock tempStock = new WS_WorkShopStock();

            tempStock.BatchNo    = subsidiary.BatchNo;
            tempStock.GoodsID    = subsidiary.GoodsID;
            tempStock.StockCount = (bool)tempOperationType.DepartmentType ? subsidiary.OperationCount : -subsidiary.OperationCount;
            tempStock.WSCode     = subsidiary.WSCode;

            PlusReductionStock(ctx, tempStock);
        }
        private void txtBatchNo_OnCompleteSearch()
        {
            txtBatchNo.Text = txtBatchNo.DataResult["批次号"].ToString();

            WS_WorkShopStock tempStock = m_serverStock.GetStockSingleInfo(cmbWSCode.SelectedValue.ToString(),
                                                                          Convert.ToInt32(txtCode.Tag),
                                                                          txtBatchNo.DataResult["批次号"].ToString());

            lbStockCount.Text = tempStock == null ? "0" : tempStock.StockCount.ToString();
        }
        /// <summary>
        /// 操作明细账(并且操作库存)
        /// </summary>
        /// <param name="subsidiary">明细账对象</param>
        public void OperationSubsidiary(WS_Subsidiary subsidiary)
        {
            if (!Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启车间管理模块]))
            {
                return;
            }

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            BASE_SubsidiaryOperationType tempOperationType = UniversalFunction.GetSubsidiaryOperationType(subsidiary.OperationType);

            if (tempOperationType == null)
            {
                throw new Exception("明细账操作类型错误,请重新确认");
            }

            var varData = from a in ctx.WS_Subsidiary
                          where a.BillNo == subsidiary.BillNo &&
                          a.GoodsID == subsidiary.GoodsID &&
                          a.WSCode == subsidiary.WSCode &&
                          a.BatchNo == subsidiary.BatchNo
                          select a;

            if (varData.Count() > 0)
            {
                throw new Exception(UniversalFunction.GetGoodsMessage(subsidiary.GoodsID) + " 【批次号】: "
                                    + subsidiary.BatchNo + " 相同单据中,物品重复,请重新确认");
            }
            else
            {
                subsidiary.BillTime = ServerTime.Time;
                ctx.WS_Subsidiary.InsertOnSubmit(subsidiary);

                WS_WorkShopStock tempStock = new WS_WorkShopStock();

                tempStock.BatchNo    = subsidiary.BatchNo;
                tempStock.GoodsID    = subsidiary.GoodsID;
                tempStock.StockCount = (bool)tempOperationType.DepartmentType ? subsidiary.OperationCount : -subsidiary.OperationCount;
                tempStock.WSCode     = subsidiary.WSCode;

                PlusReductionStock(ctx, tempStock);
            }

            ctx.SubmitChanges();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息</returns>
        S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext dataContxt, S_ScrapBill bill, S_ScrapGoods item)
        {
            Service_Manufacture_WorkShop.IWorkShopStock serverWSStock =
                Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopStock>();
            Service_Manufacture_WorkShop.IWorkShopBasic serverWSBasic =
                Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopBasic>();
            WS_WorkShopCode tempWSCode = serverWSBasic.GetPersonnelWorkShop(dataContxt, bill.FillInPersonnelCode);

            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            string error = "";

            if (!m_serverProductCode.UpdateProductStock(dataContxt, bill.Bill_ID, "报废", "05", false, item.GoodsID, out error))
            {
                throw new Exception(error);
            }

            detailBill.ID          = Guid.NewGuid();
            detailBill.FetchBIllID = bill.Bill_ID;
            detailBill.BillTime    = ServerTime.Time;
            detailBill.FetchCount  = -(decimal)item.Quantity;
            detailBill.GoodsID     = item.GoodsID;
            detailBill.BatchNo     = item.BatchNo == "无批次" ? "" : item.BatchNo;

            WS_WorkShopStock tempWSStock = new WS_WorkShopStock();

            if (tempWSCode != null)
            {
                tempWSStock = serverWSStock.GetStockSingleInfo(dataContxt, tempWSCode.WSCode, item.GoodsID, item.BatchNo);
            }

            detailBill.UnitPrice        = tempWSStock == null ? 0 : tempWSStock.UnitPrice;
            detailBill.Price            = detailBill.UnitPrice * (decimal)detailBill.FetchCount;
            detailBill.Provider         = item.Provider;
            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.OperationType    = (int)CE_SubsidiaryOperationType.报废;
            detailBill.Remark           = "【报废】";
            detailBill.FillInDate       = bill.Bill_Time;

            return(detailBill);
        }
        /// <summary>
        /// 加减库存
        /// </summary>
        /// <param name="workShopStock">加减库存记录</param>
        public void PlusReductionStock(WS_WorkShopStock workShopStock)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.WS_WorkShopStock
                          where a.GoodsID == workShopStock.GoodsID &&
                          a.BatchNo == workShopStock.BatchNo &&
                          a.WSCode == workShopStock.WSCode
                          select a;


            if (varData.Count() == 0)
            {
                if (workShopStock.StockCount < 0)
                {
                    throw new Exception(UniversalFunction.GetGoodsMessage(workShopStock.GoodsID) + " 【批次号】: "
                                        + workShopStock.BatchNo + " 操作后库存不允许小于0 ,请重新确认");
                }

                ctx.WS_WorkShopStock.InsertOnSubmit(workShopStock);
            }
            else if (varData.Count() == 1)
            {
                WS_WorkShopStock lnqTemp = varData.Single();

                lnqTemp.StockCount = lnqTemp.StockCount + workShopStock.StockCount;

                if (lnqTemp.StockCount < 0)
                {
                    throw new Exception(UniversalFunction.GetGoodsMessage(workShopStock.GoodsID) + " 【批次号】: "
                                        + workShopStock.BatchNo + " 操作后库存不允许小于0 ,请重新确认");
                }
            }
            else
            {
                throw new Exception(UniversalFunction.GetGoodsMessage(workShopStock.GoodsID) + " 【批次号】: "
                                    + workShopStock.BatchNo + " 库存表数据重复");
            }

            ctx.SubmitChanges();
        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }

            txtCode.Tag = dataGridView1.CurrentRow.Cells["物品ID"].Value;

            txtBatchNo.Text         = dataGridView1.CurrentRow.Cells["批次号"].Value.ToString();
            txtCode.Text            = dataGridView1.CurrentRow.Cells["图号型号"].Value.ToString();
            txtName.Text            = dataGridView1.CurrentRow.Cells["物品名称"].Value.ToString();
            txtSpec.Text            = dataGridView1.CurrentRow.Cells["规格"].Value.ToString();
            txtListRemark.Text      = dataGridView1.CurrentRow.Cells["备注"].Value.ToString();
            numOperationCount.Value = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["数量"].Value);
            lbHYDW.Text             = dataGridView1.CurrentRow.Cells["单位"].Value.ToString();
            lbKCDW.Text             = dataGridView1.CurrentRow.Cells["单位"].Value.ToString();

            WS_WorkShopStock tempStock = m_serverStock.GetStockSingleInfo(cmbWSCode.SelectedValue.ToString(),
                                                                          Convert.ToInt32(txtCode.Tag), txtBatchNo.Text);

            lbStockCount.Text = tempStock == null ? "0" : tempStock.StockCount.ToString();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 确认单据
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="list">明细信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AffirmBill(string billNo, DataTable list, out string error)
        {
            error = null;

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            ctx.Connection.Open();
            ctx.Transaction = ctx.Connection.BeginTransaction();

            try
            {
                var varData = from a in ctx.WS_ConsumptionBill
                              where a.BillNo == billNo
                              select a;

                WS_ConsumptionBill tempBill = new WS_ConsumptionBill();

                if (varData.Count() == 1)
                {
                    tempBill = varData.Single();

                    if (tempBill.BillStatus != ConsumptionBillStatus.等待确认.ToString())
                    {
                        throw new Exception("单据状态错误,请重新确认");
                    }

                    tempBill.BillStatus = ConsumptionBillStatus.单据已完成.ToString();
                    tempBill.Affirm     = BasicInfo.LoginName;
                    tempBill.AffirmDate = ServerTime.Time;
                }
                else
                {
                    throw new Exception("数据不唯一,请重新确认");
                }


                ListControl(ctx, tempBill, list);
                ctx.SubmitChanges();

                foreach (DataRow dr in list.Rows)
                {
                    WS_Subsidiary tempSubsidiary = new WS_Subsidiary();

                    tempSubsidiary.BatchNo        = dr["批次号"].ToString();
                    tempSubsidiary.BillNo         = tempBill.BillNo;
                    tempSubsidiary.GoodsID        = Convert.ToInt32(dr["物品ID"]);
                    tempSubsidiary.OperationCount = Convert.ToDecimal(dr["数量"]);
                    tempSubsidiary.OperationType  = (int)CE_SubsidiaryOperationType.车间耗用;
                    tempSubsidiary.Remark         = dr["备注"].ToString();
                    tempSubsidiary.WSCode         = tempBill.WSCode;
                    tempSubsidiary.Proposer       = tempBill.Proposer;
                    tempSubsidiary.ProposerDate   = (DateTime)tempBill.ProposerDate;
                    tempSubsidiary.Affirm         = BasicInfo.LoginName;
                    tempSubsidiary.AffirmDate     = ServerTime.Time;

                    IWorkShopStock   serverStock = ServerModuleFactory.GetServerModule <IWorkShopStock>();
                    WS_WorkShopStock tempWSStock = serverStock.GetStockSingleInfo(tempSubsidiary.WSCode,
                                                                                  tempSubsidiary.GoodsID,
                                                                                  tempSubsidiary.BatchNo);

                    tempSubsidiary.UnitPrice = tempWSStock == null ? 0 : tempWSStock.UnitPrice;
                    tempSubsidiary.BillTime  = ServerTime.Time;

                    View_HR_Personnel tempHR = UniversalFunction.GetPersonnelInfo(tempSubsidiary.Proposer);

                    if (tempHR == null)
                    {
                        throw new Exception("申请人员不存在");
                    }

                    tempSubsidiary.Applicant = tempHR.部门名称;

                    serverStock.OperationSubsidiary(ctx, tempSubsidiary);
                }

                ctx.SubmitChanges();
                ctx.Transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 确认单据
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="list">明细信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AffirmBill(string billNo, DataTable list, out string error)
        {
            error = null;

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            ctx.Connection.Open();
            ctx.Transaction = ctx.Connection.BeginTransaction();

            try
            {
                var varData = from a in ctx.WS_CannibalizeBill
                              where a.BillNo == billNo
                              select a;

                WS_CannibalizeBill tempBill = new WS_CannibalizeBill();

                if (varData.Count() == 1)
                {
                    tempBill = varData.Single();

                    if (tempBill.BillStatus != CannibalizeBillStatus.等待确认.ToString())
                    {
                        throw new Exception("单据状态错误,请重新确认");
                    }

                    tempBill.BillStatus = CannibalizeBillStatus.单据已完成.ToString();
                    tempBill.Affirm     = BasicInfo.LoginName;
                    tempBill.AffirmDate = ServerTime.Time;
                }
                else
                {
                    throw new Exception("数据不唯一,请重新确认");
                }

                var varCannibalizeWSCode = from a in ctx.WS_CannibalizeWSCode
                                           where a.BillNo == tempBill.BillNo
                                           select a;

                ListControl(ctx, tempBill, varCannibalizeWSCode.ToList <WS_CannibalizeWSCode>(), list);
                ctx.SubmitChanges();

                var varOperationType = from a in varCannibalizeWSCode
                                       join b in ctx.BASE_SubsidiaryOperationType
                                       on a.OperationType equals b.OperationType
                                       orderby b.DepartmentType
                                       select a;

                var varGoodsList = from a in ctx.WS_CannibalizeList
                                   where a.BillNo == tempBill.BillNo
                                   select a;

                foreach (WS_CannibalizeList tempItem in varGoodsList)
                {
                    decimal unitPrice = 0;

                    foreach (WS_CannibalizeWSCode item in varOperationType)
                    {
                        WS_Subsidiary tempSubsidiary = new WS_Subsidiary();

                        tempSubsidiary.BatchNo        = tempItem.BatchNo;
                        tempSubsidiary.BillNo         = tempBill.BillNo;
                        tempSubsidiary.GoodsID        = tempItem.GoodsID;
                        tempSubsidiary.OperationCount = tempItem.OperationCount;
                        tempSubsidiary.OperationType  = item.OperationType;
                        tempSubsidiary.Remark         = tempItem.Remark;
                        tempSubsidiary.WSCode         = item.WSCode;
                        tempSubsidiary.Proposer       = tempBill.Proposer;
                        tempSubsidiary.ProposerDate   = (DateTime)tempBill.ProposerDate;
                        tempSubsidiary.Affirm         = BasicInfo.LoginName;
                        tempSubsidiary.AffirmDate     = ServerTime.Time;
                        tempSubsidiary.BillTime       = ServerTime.Time;

                        WS_CannibalizeWSCode tempCanWSCode = new WS_CannibalizeWSCode();

                        tempCanWSCode.BillNo = tempSubsidiary.BillNo;

                        Service_Manufacture_WorkShop.IWorkShopStock serverStock =
                            Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopStock>();
                        switch (item.OperationType)
                        {
                        case (int)CE_SubsidiaryOperationType.车间调出:
                            tempCanWSCode.OperationType = (int)CE_SubsidiaryOperationType.车间调入;

                            WS_WorkShopStock tempWSStock = serverStock.GetStockSingleInfo(tempSubsidiary.WSCode,
                                                                                          tempSubsidiary.GoodsID,
                                                                                          tempSubsidiary.BatchNo);

                            unitPrice = tempWSStock == null ? 0 : tempWSStock.UnitPrice;
                            tempSubsidiary.UnitPrice = unitPrice;
                            break;

                        case (int)CE_SubsidiaryOperationType.车间调入:
                            tempCanWSCode.OperationType = (int)CE_SubsidiaryOperationType.车间调出;
                            tempSubsidiary.UnitPrice    = unitPrice;
                            break;

                        default:
                            break;
                        }

                        tempCanWSCode = GetCannibalizeWSCode(tempCanWSCode);

                        if (tempCanWSCode == null)
                        {
                            throw new Exception("调运车间信息错误");
                        }

                        Service_Manufacture_WorkShop.IWorkShopBasic serverBasic =
                            Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopBasic>();
                        WS_WorkShopCode tempCode = serverBasic.GetWorkShopCodeInfo(tempCanWSCode.WSCode);

                        if (tempCode == null)
                        {
                            throw new Exception("获取车间名称失败");
                        }

                        tempSubsidiary.Applicant = tempCode.WSName;

                        serverStock.OperationSubsidiary(ctx, tempSubsidiary);
                    }
                }

                ctx.SubmitChanges();
                ctx.Transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 检测有关数据项内容是否正确
        /// </summary>
        /// <returns>返回检测结果</returns>
        bool CheckDataItem()
        {
            if (txtName.Text.Length == 0)
            {
                MessageDialog.ShowPromptMessage("请选择物品信息");
                return(false);
            }

            //检测是否为售后库房的总成并且要求必须选择产品状态
            if (Convert.ToBoolean(UniversalFunction.GetGoodsAttributeInfo(Convert.ToInt32(txtCode.Tag), CE_GoodsAttributeName.CVT)) &&
                cmbProductStatus.Text.Trim() == "" && m_strStorage == "05")
            {
                cmbProductStatus.Focus();
                MessageDialog.ShowPromptMessage("请选择产品状态");
                return(false);
            }

            if (numReturnedCount.Value == 0)
            {
                numReturnedCount.Focus();
                MessageDialog.ShowPromptMessage("领料退库数量必须 > 0");
                return(false);
            }

            if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启车间管理模块]) && txtBatchNo.Text.Trim().Length == 0 && m_lnqWSCode != null)
            {
                Service_Manufacture_WorkShop.IWorkShopStock serverStock =
                    Service_Manufacture_WorkShop.ServerModuleFactory.GetServerModule <Service_Manufacture_WorkShop.IWorkShopStock>();

                WS_WorkShopStock tempLnq = serverStock.GetStockSingleInfo(m_lnqWSCode.WSCode, (int)txtCode.Tag, "");

                if (tempLnq == null)
                {
                    btnBatchNo.Focus();
                    MessageDialog.ShowPromptMessage("批次号不能为空");
                    return(false);
                }
            }

            if (m_promptBatchNo)
            {
                if (MessageDialog.ShowEnquiryMessage("批次号通常的表示方式为4位年、2位月、6位流水码,您确定您输入的批次号是正确的吗?") == DialogResult.No)
                {
                    txtBatchNo.Focus();
                    return(false);
                }
            }

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (txtBatchNo.Text.Trim() == dataGridView1.Rows[i].Cells["批次号"].Value.ToString() &&
                    (int)txtCode.Tag == Convert.ToInt32(dataGridView1.Rows[i].Cells["物品ID"].Value) &&
                    i != dataGridView1.CurrentRow.Index)
                {
                    MessageDialog.ShowPromptMessage("不可重复添加同批次同一种物品");
                    return(false);
                }
            }

            return(true);
        }