Пример #1
0
 private void 新建单据ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ClearMessage();
     lbDJH.Text  = m_billNoControl.GetNewBillNo();
     lbDJZT.Text = "新建单据";
     m_lnqBill   = new YX_ThreePacketsOfTheRepairBill();
 }
        public 包外返修领料明细(AuthorityFlag m_authFlag, string billID)
        {
            InitializeComponent();

            FaceAuthoritySetting.SetEnable(this.Controls, m_authFlag);
            FaceAuthoritySetting.SetVisibly(this.toolStrip, m_authFlag);
            this.toolStrip.Visible = true;

            RefreshInfo(m_serverThreePacketsOfTheRepair.GetList(billID));

            userControlDataLocalizer1.OnlyLocalize = true;

            m_lnqBill = m_serverThreePacketsOfTheRepair.GetBill(billID, out m_strErr);

            if (m_lnqBill == null)
            {
                m_lnqBill.Bill_ID = billID;
            }
            else
            {
                numMarketingStrategy.Value = Convert.ToDecimal(m_lnqBill.MarketingStrategy);
                numRepairTaskTime.Value    = Convert.ToDecimal(m_lnqBill.RepairTaskTime);
                txtPlantRemark.Text        =
                    m_lnqBill.PlantRemark == null ? "" : m_lnqBill.PlantRemark.ToString();

                SumPrice();
            }

            txtName.Enabled = btnAdd.Enabled;

            if (dataGridView1.Rows.Count == 0 && m_lnqBill != null && m_lnqBill.DJZT == "等待领料明细申请")
            {
                dataGridView1.DataSource = m_serverThreePacketsOfTheRepair.InsertThreePacketsOfTheRepairList(m_lnqBill.Bill_ID, out m_strErr);

                if (m_strErr != null)
                {
                    FormLargeMessage form = new FormLargeMessage(m_strErr, Color.Red);
                    form.ShowDialog();
                }

                btnShortcutSelect.Visible = true;
            }
            else
            {
                btnShortcutSelect.Visible = false;
            }
        }
Пример #3
0
        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.RowCount == 0)
            {
                return;
            }

            m_lnqBill = m_threePacketsOfTheRepairServer.GetBill(dataGridView1.CurrentRow.Cells["单据号"].Value.ToString(),
                                                                out m_strErr);

            if (m_lnqBill == null)
            {
                return;
            }
            else
            {
                ShowMessage();
            }
        }
        /// <summary>
        /// 插入营销出库业务
        /// </summary>
        /// <param name="contxt">数据上下文</param>
        /// <param name="threePacket">三包外售后返修单信息</param>
        /// <param name="dtListOfStorageID">库房信息</param>
        /// <param name="listTable">明细信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>插入成功返回True,插入失败返回False</returns>
        bool InsertYXCK(DepotManagementDataContext contxt, YX_ThreePacketsOfTheRepairBill threePacket,
                        DataTable dtListOfStorageID, DataTable listTable, out string error)
        {
            error = null;
            int    intDJID      = 0;
            SellIn serverSellIn = new SellIn();

            try
            {
                if (dtListOfStorageID == null || dtListOfStorageID.Rows.Count == 0)
                {
                    return(true);
                }
                else
                {
                    for (int k = 0; k < dtListOfStorageID.Rows.Count; k++)
                    {
                        string strBillID = m_serverAssignBill.AssignNewNo(serverSellIn, CE_BillTypeEnum.营销出库单.ToString());

                        S_MarketingBill lnqMarketingBill = new S_MarketingBill();

                        lnqMarketingBill.AffirmDate = ServerTime.Time;
                        lnqMarketingBill.Date       = Convert.ToDateTime(threePacket.FoundDate);
                        lnqMarketingBill.DJH        = strBillID;
                        lnqMarketingBill.DJZT_FLAG  = "已确认";
                        lnqMarketingBill.KFRY       = BasicInfo.LoginID;

                        string strDepartment = m_serverDepartment.GetDeptInfoFromPersonnelInfo(threePacket.FoundPersonnel).Rows[0]["DepartmentCode"].ToString();

                        lnqMarketingBill.LRKS       = strDepartment;
                        lnqMarketingBill.LRRY       = UniversalFunction.GetPersonnelCode(threePacket.FoundPersonnel);
                        lnqMarketingBill.SHRY       = m_serverPersonnel.GetFuzzyDeptDirector(strDepartment).ToList()[0].工号.ToString();
                        lnqMarketingBill.ShDate     = ServerTime.Time;
                        lnqMarketingBill.ObjectDept = "QT";
                        lnqMarketingBill.Remark     = "由三包外返修处理单【" + threePacket.Bill_ID + "】自动生成";
                        lnqMarketingBill.StorageID  = dtListOfStorageID.Rows[k][0].ToString();
                        lnqMarketingBill.YWFS       = "三包外返修出库";
                        lnqMarketingBill.YWLX       = "出库";

                        contxt.S_MarketingBill.InsertOnSubmit(lnqMarketingBill);

                        contxt.SubmitChanges();

                        var varID = from a in contxt.S_MarketingBill
                                    where a.DJH == lnqMarketingBill.DJH
                                    select a;

                        if (varID.Count() != 1)
                        {
                            error = "数据不唯一或者为空";
                            return(false);
                        }
                        else
                        {
                            intDJID = varID.Single().ID;
                        }

                        for (int i = 0; i < listTable.Rows.Count; i++)
                        {
                            if (Convert.ToBoolean(listTable.Rows[i]["是否为客户责任"]) &&
                                listTable.Rows[i][13].ToString().Trim() == dtListOfStorageID.Rows[k][0].ToString().Trim())
                            {
                                var varStock = from a in contxt.S_Stock
                                               where a.StorageID == dtListOfStorageID.Rows[k][0].ToString() &&
                                               a.GoodsID == Convert.ToInt32(listTable.Rows[i]["物品ID"]) &&
                                               a.BatchNo == listTable.Rows[i]["批次号"].ToString() &&
                                               a.Provider == listTable.Rows[i][14].ToString()
                                               select a;

                                if (varStock.Count() != 1)
                                {
                                    error = "库存信息不唯一或者为空";
                                    return(false);
                                }
                                else
                                {
                                    if (varStock.Single().GoodsStatus == 3)
                                    {
                                        error = "【" + varStock.Single().GoodsCode + "】 【" + varStock.Single().GoodsName + "】 【"
                                                + varStock.Single().Spec + "】【"
                                                + listTable.Rows[i]["批次号"].ToString()
                                                + "】物品库存状态为“隔离”不允许出库";

                                        return(false);
                                    }
                                }

                                S_MarketingList lnqMarketingList = new S_MarketingList();

                                lnqMarketingList.BatchNo = listTable.Rows[i]["批次号"].ToString();
                                lnqMarketingList.Count   = Convert.ToDecimal(listTable.Rows[i]["领用数量"]);
                                lnqMarketingList.CPID    = listTable.Rows[i]["物品ID"].ToString();
                                lnqMarketingList.DJ_ID   = intDJID;
                                lnqMarketingList.ReMark  = listTable.Rows[i]["备注"].ToString();
                                lnqMarketingList.Price   = Math.Round(Convert.ToDecimal(listTable.Rows[i]["单价"]) *
                                                                      Convert.ToDecimal(listTable.Rows[i]["领用数量"]), 2);
                                lnqMarketingList.Provider  = listTable.Rows[i][14].ToString();
                                lnqMarketingList.UnitPrice = Convert.ToDecimal(listTable.Rows[i]["单价"]);

                                contxt.S_MarketingList.InsertOnSubmit(lnqMarketingList);
                            }
                        }

                        contxt.SubmitChanges();

                        serverSellIn.OperationDetailAndStock_Out(contxt, lnqMarketingBill);
                        contxt.SubmitChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 插入领料单
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="threePacketsOfTheRepairBill">三包外返修处置单主表信息</param>
        /// <param name="dtListOfStorageID">库房信息</param>
        /// <param name="threePacketsOfTheRepairList">三包外返修处置单明细信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        bool InsertMaterialRequisition(DepotManagementDataContext dataContext, YX_ThreePacketsOfTheRepairBill threePacketsOfTheRepairBill,
                                       DataTable dtListOfStorageID, DataTable threePacketsOfTheRepairList, out string error)
        {
            error = null;

            try
            {
                if (dtListOfStorageID == null || dtListOfStorageID.Rows.Count == 0)
                {
                    return(true);
                }
                else
                {
                    for (int k = 0; k < dtListOfStorageID.Rows.Count; k++)
                    {
                        //领表主表信息
                        MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer();

                        string strBillID = m_serverAssignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

                        S_MaterialRequisition lnqMaterial = new S_MaterialRequisition();

                        lnqMaterial.Bill_ID             = strBillID;
                        lnqMaterial.Bill_Time           = ServerModule.ServerTime.Time;
                        lnqMaterial.AssociatedBillNo    = threePacketsOfTheRepairBill.Bill_ID;
                        lnqMaterial.AssociatedBillType  = "三包外返修处置单";
                        lnqMaterial.BillStatus          = "已出库";
                        lnqMaterial.Department          = m_serverDepartment.GetDeptInfoFromPersonnelInfo(threePacketsOfTheRepairBill.WorkShopPersonnel).Rows[0]["DepartmentCode"].ToString();
                        lnqMaterial.DepartmentDirector  = threePacketsOfTheRepairBill.WorkshopManagerPersonnel;
                        lnqMaterial.DepotManager        = threePacketsOfTheRepairBill.StockPersonnel;
                        lnqMaterial.FetchCount          = 0;
                        lnqMaterial.FetchType           = "零星领料";
                        lnqMaterial.FillInPersonnel     = threePacketsOfTheRepairBill.WorkShopPersonnel;
                        lnqMaterial.FillInPersonnelCode = UniversalFunction.GetPersonnelCode(threePacketsOfTheRepairBill.WorkShopPersonnel);
                        lnqMaterial.ProductType         = "";
                        lnqMaterial.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.包外维修).Code;
                        lnqMaterial.Remark       = "由三包外返修处置单自动生成,对应的三包外返修处置单号为" + threePacketsOfTheRepairBill.Bill_ID;
                        lnqMaterial.StorageID    = dtListOfStorageID.Rows[k][0].ToString();
                        lnqMaterial.OutDepotDate = ServerTime.Time;

                        if (!serverMaterialBill.AutoCreateBill(dataContext, lnqMaterial, out error))
                        {
                            return(false);
                        }

                        for (int i = 0; i < threePacketsOfTheRepairList.Rows.Count; i++)
                        {
                            if (!Convert.ToBoolean(threePacketsOfTheRepairList.Rows[i]["是否为客户责任"]) &&
                                threePacketsOfTheRepairList.Rows[i][13].ToString().Trim() == dtListOfStorageID.Rows[k][0].ToString().Trim())
                            {
                                var varStock = from a in dataContext.S_Stock
                                               where a.StorageID == dtListOfStorageID.Rows[k][0].ToString() &&
                                               a.GoodsID == Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"]) &&
                                               a.BatchNo == threePacketsOfTheRepairList.Rows[i]["批次号"].ToString() &&
                                               a.Provider == threePacketsOfTheRepairList.Rows[i][14].ToString()
                                               select a;

                                if (varStock.Count() != 1)
                                {
                                    error = "库存信息不唯一或者为空";
                                    return(false);
                                }
                                else
                                {
                                    if (varStock.Single().GoodsStatus == 3)
                                    {
                                        error = "【" + varStock.Single().GoodsCode + "】 【" + varStock.Single().GoodsName + "】 【"
                                                + varStock.Single().Spec + "】【"
                                                + threePacketsOfTheRepairList.Rows[i]["批次号"].ToString()
                                                + "】物品库存状态为“隔离”不允许出库";

                                        return(false);
                                    }
                                }


                                S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods();

                                lnqMaterialGoods.Bill_ID      = strBillID;
                                lnqMaterialGoods.BasicCount   = 0;
                                lnqMaterialGoods.BatchNo      = threePacketsOfTheRepairList.Rows[i]["批次号"].ToString();
                                lnqMaterialGoods.GoodsID      = Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"]);
                                lnqMaterialGoods.ProviderCode = threePacketsOfTheRepairList.Rows[i][14].ToString();
                                lnqMaterialGoods.RealCount    = Convert.ToDecimal(threePacketsOfTheRepairList.Rows[i]["领用数量"]);
                                lnqMaterialGoods.Remark       = threePacketsOfTheRepairList.Rows[i]["备注"].ToString();
                                lnqMaterialGoods.RequestCount = Convert.ToDecimal(threePacketsOfTheRepairList.Rows[i]["领用数量"]);
                                lnqMaterialGoods.ShowPosition = 1;

                                MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

                                if (!serverMaterialGoods.AutoCreateGoods(dataContext, lnqMaterialGoods, out error))
                                {
                                    return(false);
                                }
                            }
                        }

                        dataContext.SubmitChanges();

                        new MaterialRequisitionServer().OpertaionDetailAndStock(dataContext, lnqMaterial);

                        dataContext.SubmitChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = error + ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 单据流程
        /// </summary>
        /// <param name="threePacketBill">LINQ 单据数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作流程成功返回True,操作流程失败返回False</returns>
        public bool UpdateBill(YX_ThreePacketsOfTheRepairBill threePacketBill, out string error)
        {
            error = null;

            SellIn serverSellIn = new SellIn();

            DepotManagementDataContext contxt = CommentParameter.DepotDataContext;

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

            try
            {
                var varData = from a in contxt.YX_ThreePacketsOfTheRepairBill
                              where a.Bill_ID == threePacketBill.Bill_ID
                              select a;

                if (varData.Count() == 0)
                {
                    if (threePacketBill.DJZT == "新建单据")
                    {
                        threePacketBill.DJZT = "等待确认收货";
                        threePacketBill.MarketingStrategy = 0;
                        threePacketBill.RepairTaskTime    = 0;
                        threePacketBill.FoundDate         = ServerTime.Time;
                        threePacketBill.FoundPersonnel    = BasicInfo.LoginName;

                        contxt.YX_ThreePacketsOfTheRepairBill.InsertOnSubmit(threePacketBill);

                        //if (!InsertThreePacketsOfTheRepairList(contxt,threePacketBill.Bill_ID,threePacketBill.ProductType,out error))
                        //{
                        //    throw new Exception(error);
                        //}
                    }
                    else
                    {
                        error = "数据为空";
                        return(false);
                    }
                }
                else if (varData.Count() > 1)
                {
                    error = "数据不唯一";
                    return(false);
                }
                else if (varData.Count() == 1)
                {
                    YX_ThreePacketsOfTheRepairBill lnqThreePackets = varData.Single();

                    if (lnqThreePackets.DJZT != threePacketBill.DJZT)
                    {
                        error = "单据状态错误,请重新刷新单据确认单据状态";
                        return(false);
                    }

                    switch (lnqThreePackets.DJZT)
                    {
                    case "等待确认收货":
                        lnqThreePackets.DJZT = "等待领料明细申请";

                        lnqThreePackets.AOGDate      = ServerTime.Time;
                        lnqThreePackets.AOGPersonnel = BasicInfo.LoginName;

                        break;

                    case "等待领料明细申请":
                        lnqThreePackets.DJZT = "等待确认清单责任归属";

                        lnqThreePackets.PlantRemark       = threePacketBill.PlantRemark;
                        lnqThreePackets.WorkShopDate      = ServerTime.Time;
                        lnqThreePackets.WorkShopPersonnel = BasicInfo.LoginName;

                        break;

                    case "等待确认清单责任归属":
                        lnqThreePackets.DJZT = "等待返修车间主管审核";

                        lnqThreePackets.DistributeDate      = ServerTime.Time;
                        lnqThreePackets.DistributePersonnel = BasicInfo.LoginName;

                        break;

                    case "等待返修车间主管审核":
                        lnqThreePackets.DJZT = "等待仓管确认出库";

                        lnqThreePackets.PlantRemark              = threePacketBill.PlantRemark;
                        lnqThreePackets.WorkshopManagerDate      = ServerTime.Time;
                        lnqThreePackets.WorkshopManagerPersonnel = BasicInfo.LoginName;

                        break;

                    case "等待仓管确认出库":
                        lnqThreePackets.DJZT = "等待返修完成";

                        lnqThreePackets.StockDate      = ServerTime.Time;
                        lnqThreePackets.StockPersonnel = BasicInfo.LoginName;

                        DataTable listTable = GetStorageTable(GetList(lnqThreePackets.Bill_ID), out error);

                        if (listTable == null)
                        {
                            throw new Exception(error);
                        }

                        DataTable dtSellListOfStorageID =
                            GlobalObject.DataSetHelper.SelectDistinct("", GlobalObject.DataSetHelper.SiftDataTable(listTable, "是否为客户责任 = 1", out error), "StroageID");
                        //GetListOfStorageID(lnqThreePackets.Bill_ID, 1);

                        DataTable dtMaterialListOfStorageID =
                            GlobalObject.DataSetHelper.SelectDistinct("", GlobalObject.DataSetHelper.SiftDataTable(listTable, "是否为客户责任 = 0", out error), "StroageID");
                        //GetListOfStorageID(lnqThreePackets.Bill_ID, 0);

                        //自动生成营销出库单.....
                        if (!InsertYXCK(contxt, lnqThreePackets, dtSellListOfStorageID, listTable, out error))
                        {
                            throw new Exception(error);
                        }

                        //自动生成领料单.....
                        if (!InsertMaterialRequisition(contxt, lnqThreePackets, dtMaterialListOfStorageID, listTable, out error))
                        {
                            throw new Exception(error);
                        }

                        contxt.SubmitChanges();

                        CheckData(contxt, lnqThreePackets.Bill_ID);

                        break;

                    case "等待返修完成":

                        lnqThreePackets.DJZT = "等待质检检验";

                        lnqThreePackets.RepairTaskTime  = Convert.ToDecimal(threePacketBill.RepairTaskTime);
                        lnqThreePackets.PlantRemark     = threePacketBill.PlantRemark;
                        lnqThreePackets.RepairDate      = ServerTime.Time;
                        lnqThreePackets.RepairPersonnel = BasicInfo.LoginName;
                        break;

                    case "等待质检检验":

                        lnqThreePackets.DJZT             = "等待销售策略";
                        lnqThreePackets.ExamineDate      = ServerTime.Time;
                        lnqThreePackets.ExaminePersonnel = BasicInfo.LoginName;

                        break;

                    case "等待销售策略":

                        lnqThreePackets.DJZT = "等待营销主管审核";

                        lnqThreePackets.MarketingStrategy = Convert.ToDecimal(threePacketBill.MarketingStrategy);

                        lnqThreePackets.StrategyDate      = ServerTime.Time;
                        lnqThreePackets.StrategyPersonnel = BasicInfo.LoginName;

                        break;

                    case "等待营销主管审核":

                        if (Convert.ToDecimal(threePacketBill.MarketingStrategy) > 50)
                        {
                            lnqThreePackets.DJZT = "等待营销总监审核";
                        }
                        else
                        {
                            lnqThreePackets.DJZT = "等待财务确认";
                        }

                        lnqThreePackets.MarketingExecutiveDate = ServerTime.Time;
                        lnqThreePackets.MarketingExecutive     = BasicInfo.LoginName;

                        break;

                    case "等待营销总监审核":

                        lnqThreePackets.DJZT = "等待财务确认";

                        lnqThreePackets.MarketingLeaderDate      = ServerTime.Time;
                        lnqThreePackets.MarketingLeaderPersonnel = BasicInfo.LoginName;

                        break;

                    case "等待财务确认":

                        lnqThreePackets.DJZT = "已完成";

                        lnqThreePackets.FinanceDate      = ServerTime.Time;
                        lnqThreePackets.FinancePersonnel = BasicInfo.LoginName;

                        break;

                    default:
                        break;
                    }
                }

                contxt.SubmitChanges();
                contxt.Transaction.Commit();

                return(true);
            }
            catch (Exception ex)
            {
                contxt.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }