Ejemplo n.º 1
0
        public static bool ConcelConfirm(string ID, string FromType, string OrderNo, List<ProductModel> ProductMList, List<ProductModel> ProductMStorList, out string Reason)
        {
            try
            {
                Reason = string.Empty;
                //不可以确认返回false
                if (!PurchaseOrderDBHelper.CanConcel(ID, out Reason))
                    return false;
                ArrayList lstConcelConfirm = new ArrayList();
                //更新主表
                SqlCommand ConcelPri = PurchaseOrderDBHelper.ConcelConfirm(ID);
                lstConcelConfirm.Add(ConcelPri);

                //更新分仓存量表
                if (ProductMStorList != null)
                {
                    foreach (ProductModel ProductM in ProductMStorList)
                    {
                        SqlCommand comm = PurchaseOrderDBHelper.WriteStorgeDecr(ProductM);
                        lstConcelConfirm.Add(comm);
                    }
                }
                if (ProductMList != null)
                {
                    if (FromType == "2")
                    {//回写采购计划
                        foreach (ProductModel ProductM in ProductMList)
                        {
                            SqlCommand comm = PurchaseOrderDBHelper.WritePurPlanDecr(ProductM);
                            lstConcelConfirm.Add(comm);
                        }
                    }
                    else if (FromType == "4")
                    {//回写采购合同
                        foreach (ProductModel ProductM in ProductMList)
                        {
                            SqlCommand comm = PurchaseOrderDBHelper.WritePurContDecr(ProductM);
                            lstConcelConfirm.Add(comm);
                        }
                    }
                }
                //获取登陆用户信息
                UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

                //撤销审批
                string CompanyCD = userInfo.CompanyCD;
                string BillTypeFlag = ConstUtil.CODING_RULE_PURCHASE;
                string BillTypeCode = ConstUtil.CODING_RULE_PURCHASE_ORDER;
                string strUserID = userInfo.UserID; ;
                DataTable dt = FlowDBHelper.GetFlowInstanceInfo(CompanyCD, Convert.ToInt32(BillTypeFlag), Convert.ToInt32(BillTypeCode), Convert.ToInt32(ID));
                if (dt.Rows.Count > 0)
                {
                    string FlowInstanceID = dt.Rows[0]["FlowInstanceID"].ToString();
                    string FlowStatus = dt.Rows[0]["FlowStatus"].ToString();
                    string FlowNo = dt.Rows[0]["FlowNo"].ToString();

                    lstConcelConfirm.Add(FlowDBHelper.CancelConfirmHis(CompanyCD, FlowInstanceID, FlowNo, BillTypeFlag, BillTypeCode, strUserID));
                    lstConcelConfirm.Add(FlowDBHelper.CancelConfirmTsk(CompanyCD, FlowInstanceID, strUserID));
                    lstConcelConfirm.Add(FlowDBHelper.CancelConfirmIns(CompanyCD, FlowNo, BillTypeFlag, BillTypeCode, ID, strUserID));
                }

                //定义返回变量
                bool isSucc = false;
                /* 
                 * 定义日志内容变量 
                 * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
                 * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
                 */

                //执行插入操作
                try
                {
                    isSucc = SqlHelper.ExecuteTransWithArrayList(lstConcelConfirm);
                }
                catch (Exception ex)
                {
                    //输出日志
                    WriteSystemLog(userInfo, ex);
                }
                //定义变量
                string remark;
                //成功时
                if (isSucc)
                {
                    //设置操作成功标识
                    remark = ConstUtil.LOG_PROCESS_SUCCESS;
                }
                else
                {
                    //设置操作成功标识 
                    remark = ConstUtil.LOG_PROCESS_FAILED;
                }

                LogInfoModel logModel = InitLogInfo(OrderNo);
                //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
                logModel.Element = ConstUtil.LOG_PROCESS_UNCONFIRM;
                //设置操作成功标识
                logModel.Remark = remark;

                //登陆日志
                LogDBHelper.InsertLog(logModel);
                return isSucc;
            }
            catch (Exception ex)
            {
                throw ex;
            }



        }