예제 #1
0
        /// <summary>
        /// 添加父表信息
        /// </summary>
        /// <param name="marketingPlan">计划主表信息</param>
        /// <param name="planList">计划明细表信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>添加成功返回True,添加失败返回False</returns>
        public bool AddBill(S_MarketingPlanBill marketingPlan, DataTable planList, out string error)
        {
            error = null;
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                if (!IsRepeatBillID(marketingPlan.DJH))
                {
                    if (!UpdateBill(ctx, marketingPlan, planList, out error))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!DeletePlanList(ctx, marketingPlan.DJH, out error))
                    {
                        return(false);
                    }

                    if (!AddPlanList(ctx, planList, out error))
                    {
                        return(false);
                    }

                    if (!CheckBillType(ctx, marketingPlan.YearAndMonth, marketingPlan.BillType, out error))
                    {
                        return(false);
                    }

                    S_MarketingPlanBill lnqPlan = new S_MarketingPlanBill();

                    lnqPlan.DJH                 = marketingPlan.DJH;
                    lnqPlan.YearAndMonth        = marketingPlan.YearAndMonth;
                    lnqPlan.BillType            = marketingPlan.BillType;
                    lnqPlan.DJZT                = "等待采购计划批准";
                    lnqPlan.BZR                 = BasicInfo.LoginName;
                    lnqPlan.BZRQ                = ServerTime.Time;
                    lnqPlan.FirstMonthSumCount  = marketingPlan.FirstMonthSumCount;
                    lnqPlan.SecondMonthSumCount = marketingPlan.SecondMonthSumCount;
                    lnqPlan.ThirdMonthSumCount  = marketingPlan.ThirdMonthSumCount;
                    lnqPlan.Remark              = marketingPlan.Remark;
                    lnqPlan.FileNo              = marketingPlan.FileNo;

                    ctx.S_MarketingPlanBill.InsertOnSubmit(lnqPlan);
                }

                ctx.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 更改状态
        /// </summary>
        /// <param name="billStatus">单据状态</param>
        /// <param name="billIDList">计划单号列表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>更改成功返回True,更改失败返回False</returns>
        public bool UpdateBill(string billStatus, DataTable billIDList, out string error)
        {
            error = null;
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                for (int i = 0; i < billIDList.Rows.Count; i++)
                {
                    var varData = from a in ctx.S_MarketingPlanBill
                                  where a.DJH == billIDList.Rows[i]["单据号"].ToString()
                                  select a;

                    if (varData.Count() == 1)
                    {
                        S_MarketingPlanBill lnqMkPlan = varData.Single();

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

                        switch (lnqMkPlan.DJZT)
                        {
                        case "等待主管审核":
                            lnqMkPlan.DJZT = "等待领导批准";
                            lnqMkPlan.SHR  = BasicInfo.LoginName;
                            lnqMkPlan.SHRQ = ServerTime.Time;
                            break;

                        case "等待领导批准":
                            lnqMkPlan.DJZT = "等待采购计划批准";
                            lnqMkPlan.PZR  = BasicInfo.LoginName;
                            lnqMkPlan.PZRQ = ServerTime.Time;
                            break;

                        default:
                            break;
                        }

                        ctx.SubmitChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// 修改父表信息
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="inMkPlan">采购计划主表信息</param>
        /// <param name="planList">采购计划明细信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>修改成功返回True,修改失败返回False</returns>
        private bool UpdateBill(DepotManagementDataContext ctx, S_MarketingPlanBill inMkPlan, DataTable planList, out string error)
        {
            error = null;

            try
            {
                var varData = from a in ctx.S_MarketingPlanBill
                              where a.DJH == inMkPlan.DJH
                              select a;

                if (varData.Count() == 1)
                {
                    if (!DeletePlanList(ctx, inMkPlan.DJH, out error))
                    {
                        return(false);
                    }

                    if (!AddPlanList(ctx, planList, out error))
                    {
                        return(false);
                    }

                    if (!CheckBillType(ctx, inMkPlan.YearAndMonth, inMkPlan.BillType, out error))
                    {
                        return(false);
                    }

                    S_MarketingPlanBill lnqPlan = varData.Single();

                    lnqPlan.DJZT                = "等待采购计划批准";
                    lnqPlan.BillType            = inMkPlan.BillType;
                    lnqPlan.YearAndMonth        = inMkPlan.YearAndMonth;
                    lnqPlan.BZR                 = BasicInfo.LoginName;
                    lnqPlan.BZRQ                = ServerTime.Time;
                    lnqPlan.FirstMonthSumCount  = inMkPlan.FirstMonthSumCount;
                    lnqPlan.SecondMonthSumCount = inMkPlan.SecondMonthSumCount;
                    lnqPlan.ThirdMonthSumCount  = inMkPlan.ThirdMonthSumCount;
                    lnqPlan.Remark              = inMkPlan.Remark;
                    lnqPlan.FileNo              = inMkPlan.FileNo;

                    ctx.SubmitChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
예제 #4
0
        public void UpdateFilePath(string billNo, string fileNo)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.S_MarketingPlanBill
                          where a.DJH == billNo
                          select a;

            if (varData.Count() == 1)
            {
                S_MarketingPlanBill tempInfo = varData.Single();
                tempInfo.FileNo = fileNo;
            }

            ctx.SubmitChanges();
        }
예제 #5
0
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="djh">计划单号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>删除成功返回True,删除失败返回False</returns>
        public bool DeleteBill(string djh, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.S_MarketingPlanBill
                              where a.DJH == djh
                              select a;

                if (varData.Count() == 1)
                {
                    S_MarketingPlanBill lnqMarketingPlan = varData.Single();

                    if (DeletePlanList(ctx, djh, out error))
                    {
                        ctx.S_MarketingPlanBill.DeleteOnSubmit(lnqMarketingPlan);
                        ctx.SubmitChanges();
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    error = "数据不唯一";
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }