Ejemplo n.º 1
0
        /// <summary>
        /// 操作业务
        /// </summary>
        /// <param name="buyingBill">单据信息数据集</param>
        /// <param name="listInfo">单据明细信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool OperationInfo(Out_BuyingBill buyingBill, DataTable listInfo, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                var varData = from a in dataContext.Out_BuyingBill
                              where a.ID == buyingBill.ID
                              select a;

                if (varData.Count() == 1)
                {
                    Out_BuyingBill lnqBill = varData.Single();

                    lnqBill.Statua     = "已完成";
                    lnqBill.Director   = BasicInfo.LoginID;
                    lnqBill.DirectTime = ServerTime.Time;

                    for (int i = 0; i < listInfo.Rows.Count; i++)
                    {
                        Out_DetailAccount lnqDetail = new Out_DetailAccount();

                        lnqDetail.Bill_ID        = buyingBill.ID.ToString();
                        lnqDetail.BillFinishTime = ServerTime.Time;
                        lnqDetail.Confirmor      = BasicInfo.LoginID;
                        lnqDetail.GoodsID        = Convert.ToInt32(listInfo.Rows[i]["GoodsID"]);
                        lnqDetail.OperationCount = -Convert.ToDecimal(listInfo.Rows[i]["挂账数量"]);
                        lnqDetail.BatchNo        = listInfo.Rows[i]["规格"].ToString();
                        lnqDetail.Proposer       = buyingBill.Recorder;
                        lnqDetail.Remark         = "【挂账单】" + listInfo.Rows[i]["备注"].ToString();
                        lnqDetail.SecStorageID   = buyingBill.ClientCode;
                        lnqDetail.StorageID      = GetStockInfo(buyingBill.ClientCode, Convert.ToInt32(listInfo.Rows[i]["GoodsID"]));

                        if (!new BusinessOperation().OperationDetailAndStock(dataContext, lnqDetail, out error))
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    error = "数据不唯一";
                    return(false);
                }

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 提交申请
        /// </summary>
        /// <param name="buyingBill">单据信息数据集</param>
        /// <param name="listInfo">明细信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool InsertBill(Out_BuyingBill buyingBill, DataTable listInfo, out string error)
        {
            error = null;
            DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

            try
            {
                dataContext.Connection.Open();
                dataContext.Transaction = dataContext.Connection.BeginTransaction();

                var varData = from a in dataContext.Out_BuyingBill
                              where a.ID == buyingBill.ID
                              select a;

                if (varData.Count() == 0)
                {
                    dataContext.Out_BuyingBill.InsertOnSubmit(buyingBill);
                    dataContext.SubmitChanges();

                    if (!InsertList(dataContext, buyingBill.ID, listInfo, out error))
                    {
                        throw new Exception(error);
                    }
                }
                else if (varData.Count() == 1)
                {
                    Out_BuyingBill lnqBill = varData.Single();

                    lnqBill.Statua     = "等待审核";
                    lnqBill.Recorder   = BasicInfo.LoginID;
                    lnqBill.RecordTime = ServerTime.Time;
                    lnqBill.Remark     = buyingBill.Remark;
                    lnqBill.ClientCode = buyingBill.ClientCode;

                    if (!DeleteList(dataContext, buyingBill.ID, out error))
                    {
                        return(false);
                    }

                    if (!InsertList(dataContext, buyingBill.ID, listInfo, out error))
                    {
                        return(false);
                    }
                }
                else
                {
                    error = "数据重复";
                    return(false);
                }

                dataContext.SubmitChanges();

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