コード例 #1
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            /*
             * MonthlyStatementDataJson msd = new MonthlyStatementDataJson();
             * MonthlyStatementDataInfo[] msdi = new MonthlyStatementDataInfo[1];
             * msdi[0] = new MonthlyStatementDataInfo();
             * msdi[0].sAppendTime = DateTime.Now;
             *
             * MonthlyStatementAppendDataInfo[] msad = new MonthlyStatementAppendDataInfo[1];
             * msad[0] = new MonthlyStatementAppendDataInfo();
             * msad[0].aAppendTime = DateTime.Now;
             *
             * msd.MonthlyStatementAppendData = msad;
             * msd.MonthlyStatementData = msdi;
             *
             * MonthlyStatementDataJsonStr = JavaScriptConvert.SerializeObject(msd);
             */
            if (this.userid > 0)
            {
                string format = "";
                format = HTTPRequest.GetString("format");
                sType  = HTTPRequest.GetInt("sType", -1);
                if (sType > -1 || format == "json")
                {
                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-1") || CheckUserPopedoms("6-6-1-2") || CheckUserPopedoms("6-6-1-3") || CheckUserPopedoms("6-6-1-4") || CheckUserPopedoms("6-6-1-5") || CheckUserPopedoms("6-6-1-6") || CheckUserPopedoms("6-6-2-1") || CheckUserPopedoms("6-6-2-2") || CheckUserPopedoms("6-6-2-3") || CheckUserPopedoms("6-6-2-4") || CheckUserPopedoms("6-6-2-5") || CheckUserPopedoms("6-6-2-6") || CheckUserPopedoms("6-6-3-1") || CheckUserPopedoms("6-6-3-2") || CheckUserPopedoms("6-6-3-3") || CheckUserPopedoms("6-6-3-4") || CheckUserPopedoms("6-6-3-5") || CheckUserPopedoms("6-6-3-6"))
                    {
                        Act = Utils.ChkSQL(HTTPRequest.GetString("Act")).Trim();
                        #region 权限判断
                        switch (Act)
                        {
                        case "Add":
                        case "0":
                            switch (sType)
                            {
                            case 2:        //应收
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-2"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 创建应收对账单权限!");
                                }
                                break;

                            case 1:        //应付
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-2-2"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 创建应付对账单权限!");
                                }
                                break;

                            case 3:        //其他
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-3-2"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 创建其他类型对账单权限!");
                                }
                                break;
                            }
                            break;

                        case "Edit":
                        case "v":
                            if (ispost)
                            {
                                switch (sType)
                                {
                                case 2:        //应收
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-4"))
                                    {
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,需 修改应收对账单权限!");
                                    }
                                    break;

                                case 1:        //应付
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-2-4"))
                                    {
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,需 修改应付对账单权限!");
                                    }
                                    break;

                                case 3:        //其他
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-3-4"))
                                    {
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,需 修改其他类型对账单权限!");
                                    }
                                    break;
                                }
                            }
                            else
                            {
                                switch (sType)
                                {
                                case 2:        //应收
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-1"))
                                    {
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,需 查看应收对账单权限!");
                                    }
                                    break;

                                case 1:        //应付
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-2-1"))
                                    {
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,需 查看应付对账单权限!");
                                    }
                                    break;

                                case 3:        //其他
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-3-1"))
                                    {
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,需 查看其他类型对账单权限!");
                                    }
                                    break;
                                }
                            }
                            break;

                        case "1":    //完成对账
                        case "d":
                            switch (sType)
                            {
                            case 2:        //应收
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-3"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 完成对账 权限!");
                                }
                                break;

                            case 1:        //应付
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-2-3"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 完成对账 权限!");
                                }
                                break;

                            case 3:        //其他
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-3-3"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 完成对账 权限!");
                                }
                                break;
                            }
                            break;

                        case "2":    //到款
                        case "m":
                            switch (sType)
                            {
                            case 2:        //应收
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-5"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 完成到款 权限!");
                                }
                                break;

                            case 1:        //应付
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-2-5"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 完成到款 权限!");
                                }
                                break;

                            case 3:        //其他
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-3-5"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 完成到款 权限!");
                                }
                                break;
                            }
                            break;

                        case "3":    //结账
                        case "e":
                            switch (sType)
                            {
                            case 2:        //应收
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-6"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 结账 权限!");
                                }
                                break;

                            case 1:        //应付
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-2-6"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 结账 权限!");
                                }
                                break;

                            case 3:        //其他
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-3-6"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 结账 权限!");
                                }
                                break;
                            }
                            break;

                        case "i":    //作废
                            switch (sType)
                            {
                            case 2:        //应收
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-1-7"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 作废 权限!");
                                }
                                break;

                            case 1:        //应付
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-2-7"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 作废 权限!");
                                }
                                break;

                            case 3:        //其他
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-6-3-7"))
                                {
                                }
                                else
                                {
                                    AddErrLine("权限不足,需 作废 权限!");
                                }
                                break;
                            }
                            break;
                        }
                        #endregion ;

                        if (!IsErr())
                        {
                            MonthlyStatementID = HTTPRequest.GetInt("MonthlyStatementID", 0);
                            string  MonthlyStatementWorkingLogMsg = HTTPRequest.GetString("MonthlyStatementWorkingLogMsg");
                            int     sObjectID     = HTTPRequest.GetInt("sObjectID", 0);
                            int     sObjectType   = HTTPRequest.GetInt("sObjectType", 0);
                            decimal sUpMoney      = 0; // (HTTPRequest.GetString("sUpMoney").Trim() != "") ? Convert.ToDecimal(HTTPRequest.GetString("sUpMoney").Trim()) : 0;
                            decimal sThisMoney    = (HTTPRequest.GetString("sThisMoney").Trim() != "") ? Convert.ToDecimal(HTTPRequest.GetString("sThisMoney").Trim()) : 0;
                            decimal sMoney        = 0; // (HTTPRequest.GetString("sMoney").Trim() != "") ? Convert.ToDecimal(HTTPRequest.GetString("sMoney").Trim()) : 0;
                            decimal sToMoney      = (HTTPRequest.GetString("sToMoney").Trim() != "") ? Convert.ToDecimal(HTTPRequest.GetString("sToMoney").Trim()) : 0;
                            decimal sBalanceMoney = 0; // (HTTPRequest.GetString("sBalanceMoney").Trim() != "") ? Convert.ToDecimal(HTTPRequest.GetString("sBalanceMoney").Trim()) : 0;

                            int      sBalanceType  = HTTPRequest.GetInt("sBalanceType", 0);
                            int      sReceiptState = HTTPRequest.GetInt("sReceiptState", 0);
                            DateTime sDateTime     = (HTTPRequest.GetString("sDateTime").Trim() != "") ? Convert.ToDateTime(Utils.ChkSQL(HTTPRequest.GetString("sDateTime"))) : DateTime.Now;

                            string _MonthlyStatementDataJson = HTTPRequest.GetString("MonthlyStatementDataJson");



                            DepartmentsJson   = Caches.GetDepartmentsClassInfoToJson(-1, true, true);
                            SupplierJson      = Caches.GetSupplierClassInfoToJson(-1, true, true);
                            CustomersJson     = Caches.GetCustomersClassInfoToJson(-1, true, true);
                            PaymentSystemJson = Caches.GetPaymentSystemJson();

                            #region 获取同步骤的下一对账单信息,对账确认,到款,结账
                            if ((",1,d,2,m,3,e,").IndexOf(Act) > -1)
                            {
                                int sSteps = 0;
                                switch (Act)
                                {
                                case "1":
                                case "d":
                                    sSteps = 0;
                                    break;

                                case "2":
                                case "m":
                                    sSteps = 1;
                                    break;

                                case "3":
                                case "e":
                                    sSteps = 2;
                                    break;
                                }
                                DataSet NextDS = MonthlyStatements.GetMonthlyStatementInfoList(1, " MonthlyStatementID>" + MonthlyStatementID + " and sSteps=" + sSteps + "", " MonthlyStatementID asc");
                                if (NextDS != null)
                                {
                                    if (NextDS.Tables[0].Rows.Count > 0)
                                    {
                                        NextMonthlyStatementID = Convert.ToInt32(NextDS.Tables[0].Rows[0]["MonthlyStatementID"].ToString());
                                    }
                                }
                            }
                            #endregion

                            switch (Act)
                            {
                                #region 新建
                            case "Add":
                            case "0":
                                if (ispost)
                                {
                                    ms.sCode = MonthlyStatements.GetNewNum();
                                    if (!MonthlyStatements.ExistsMonthlyStatementInfo(ms.sCode))
                                    {
                                        ms.sObjectID     = sObjectID;
                                        ms.sObjectType   = sObjectType;
                                        ms.sType         = sType;
                                        ms.sUpMoney      = sUpMoney;
                                        ms.sThisMoney    = sThisMoney;
                                        ms.sMoney        = sMoney;
                                        ms.sToMoney      = sToMoney;
                                        ms.sBalanceMoney = sBalanceMoney;
                                        ms.sSteps        = 0;
                                        ms.sBalanceType  = sBalanceType;
                                        ms.sReceiptState = sReceiptState;
                                        ms.sDateTime     = sDateTime;
                                        ms.sState        = 0;
                                        ms.UserID        = this.userid;
                                        ms.sAppendTime   = DateTime.Now;

                                        ms.MonthlyStatementDataJson = (MonthlyStatementDataJson)JavaScriptConvert.DeserializeObject(_MonthlyStatementDataJson, typeof(MonthlyStatementDataJson));

                                        MonthlyStatementID = MonthlyStatements.AddMonthlyStatementInfo(ms);
                                        if (MonthlyStatementID > 0)
                                        {
                                            AddMsgLine("对账单创建成功!<p class=\"SendGood\"><br>继续开单?-><a href=\"javascript:void(0);\" onclick=\"javascript:MonthlyStatementList_do.Re(" + MonthlyStatementID + ");\">开单</a><br>查看单据?-><a href=\"javascript:void(0);\" onclick=\"javascript:MonthlyStatementList_do.Show(" + MonthlyStatementID + "," + sType + ");\">查看</a></p>");

                                            MonthlyStatementWorkingLogInfo mwl = new MonthlyStatementWorkingLogInfo();
                                            mwl.MonthlyStatementID = MonthlyStatementID;
                                            mwl.UserID             = this.userid;
                                            mwl.mType       = 0;
                                            mwl.mMsg        = MonthlyStatementWorkingLogMsg;
                                            mwl.mAppendTime = DateTime.Now;

                                            MonthlyStatements.AddMonthlyStatementWorkingLogInfo(mwl);

                                            MonthlyStatements.UpdateMonthlyStatementSteps(MonthlyStatementID, 0);
                                        }
                                        else
                                        {
                                            AddErrLine("对账单创建失败,请重试!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("对账单号重复,请重试!");
                                    }
                                }
                                break;

                                #endregion
                                #region 修改
                            case "Edit":
                            case "v":
                                ms = MonthlyStatements.GetMonthlyStatementInfoModel(MonthlyStatementID);
                                if (ms != null)
                                {
                                    if (!ispost)
                                    {
                                        DataTable tmsd  = new DataTable();
                                        DataTable tmsad = new DataTable();

                                        #region 单据列表
                                        tmsd = MonthlyStatements.GetMonthlyStatementDataInfoList(" MonthlyStatementID=" + MonthlyStatementID + " order by sAppendTime desc").Tables[0];
                                        string MonthlyStatementDataStr = "";
                                        if (tmsd != null)
                                        {
                                            if (tmsd.Rows.Count > 0)
                                            {
                                                foreach (DataRow dr in tmsd.Rows)
                                                {
                                                    MonthlyStatementDataStr += " {\"MonthlyStatementDataID\":\"" + dr["MonthlyStatementDataID"].ToString() + "\",\"MonthlyStatementID\":\"" + dr["MonthlyStatementID"].ToString() + "\",\"OrderID\":\"" + dr["OrderID"].ToString() + "\"," +
                                                                               "\"oMoney\":\"" + dr["oMoney"].ToString() + "\",\"sRemake\":\"" + dr["sRemake"].ToString() + "\",\"sAppendTime\":\"" + dr["sAppendTime"].ToString() + "\"," + "\"StoresSupplierName\":\"" + dr["StoresSupplierName"].ToString() + "\"," +
                                                                               "\"oOrderNum\":\"" + dr["oOrderNum"].ToString() + "\",\"oOrderDateTime\":\"" + Convert.ToDateTime(dr["oOrderDateTime"].ToString()).ToString("yyyy-MM-dd") + "\",\"StaffName\":\"" + dr["StaffName"].ToString() + "\",\"oTypeStr\":\"" + GetOrderType(dr["oType"].ToString()) + "\",\"oType\":\"" + dr["oType"].ToString() + "\"},";
                                                }
                                            }
                                        }
                                        if (MonthlyStatementDataStr.Trim() != "")
                                        {
                                            MonthlyStatementDataStr = MonthlyStatementDataStr.Substring(0, MonthlyStatementDataStr.Length - 1);
                                        }
                                        MonthlyStatementDataStr = "\"MonthlyStatementData\":[" + MonthlyStatementDataStr + "]";
                                        #endregion

                                        #region 凭证列表
                                        string MonthlyStatementAppendDataStr = "";
                                        tmsad = MonthlyStatements.GetMonthlyStatementAppendDataInfoList(" MonthlyStatementID=" + MonthlyStatementID + " and aState=0 order by aAppendTime desc").Tables[0];
                                        if (tmsad != null)
                                        {
                                            if (tmsad.Rows.Count > 0)
                                            {
                                                foreach (DataRow dr in tmsad.Rows)
                                                {
                                                    MonthlyStatementAppendDataStr += "{\"MonthlyStatementAppendDataID\":\"" + dr["MonthlyStatementAppendDataID"].ToString() + "\",\"MonthlyStatementID\":\"" + dr["MonthlyStatementID"].ToString() + "\",\"CertificateID\":\"" + dr["CertificateID"].ToString() + "\"," +
                                                                                     "\"aState\":\"" + dr["aState"].ToString() + "\",\"aRemake\":\"" + dr["aRemake"].ToString() + "\"," +
                                                                                     "\"cCode\":\"" + Convert.ToDateTime(dr["cDateTime"]).ToString("yyyyMMdd") + "-" + (dr["cNumber"].ToString()).PadLeft(config.CertificateCodeLen, '0') + "\"," +
                                                                                     "\"toObjectName\":\"" + dr["toObjectName"].ToString() + "\"," +
                                                                                     "\"aAppendTime\":\"" + dr["aAppendTime"].ToString() + "\",\"cMoney\":\"" + dr["cMoney"].ToString() + "\"," +
                                                                                     "\"cType\":\"" + dr["cType"].ToString() + "\",\"cTypeStr\":\"" + GetCertificateType(dr["cType"].ToString()) + "\"," +
                                                                                     "\"UserID\":\"" + dr["UserID"].ToString() + "\",\"UserName\":\"" + dr["UserName"].ToString() + "\"," +
                                                                                     "\"UserStaffName\":\"" + dr["UserStaffName"].ToString() + "\",\"StaffName\":\"" + dr["StaffName"].ToString() + "\"," +
                                                                                     "\"StaffID\":\"" + dr["StaffID"].ToString() + "\",\"cDateTime\":\"" + Convert.ToDateTime(dr["cDateTime"].ToString()).ToString("yyyy-MM-dd") + "\"," +
                                                                                     "\"cObject\":\"" + dr["cObject"].ToString() + "\",\"cObjectID\":\"" + dr["cObjectID"].ToString() + "\"},";
                                                }
                                            }
                                        }
                                        if (MonthlyStatementAppendDataStr.Trim() != "")
                                        {
                                            MonthlyStatementAppendDataStr = MonthlyStatementAppendDataStr.Substring(0, MonthlyStatementAppendDataStr.Length - 1);
                                        }
                                        MonthlyStatementAppendDataStr = "\"MonthlyStatementAppendData\":[" + MonthlyStatementAppendDataStr + "]";
                                        #endregion

                                        #region 发生金额列表
                                        string MonthlyStatementAppendMoneyDataStr = "";
                                        tmsad = MonthlyStatements.GetMonthlyStatementAppendMoneyDataInfoList(" MonthlyStatementID=" + MonthlyStatementID + " and mState=0 order by mAppendTime desc").Tables[0];
                                        if (tmsad != null)
                                        {
                                            if (tmsad.Rows.Count > 0)
                                            {
                                                foreach (DataRow dr in tmsad.Rows)
                                                {
                                                    MonthlyStatementAppendMoneyDataStr += "{\"MonthlyStatementAppendMoneyDataID\":\"" + dr["MonthlyStatementAppendMoneyDataID"].ToString() + "\",\"MonthlyStatementID\":\"" + dr["MonthlyStatementID"].ToString() + "\",\"mMoney\":\"" + dr["mMoney"].ToString() + "\",\"mDateTime\":\"" + Convert.ToDateTime(dr["mDateTime"]).ToString("yyyy-MM-dd") + "\",\"mState\":\"" + dr["mState"].ToString() + "\",\"mRemake\":\"" + dr["mRemake"].ToString() + "\",\"mAppendTime\":\"" + dr["mAppendTime"].ToString() + "\"},";
                                                }
                                            }
                                        }
                                        if (MonthlyStatementAppendMoneyDataStr.Trim() != "")
                                        {
                                            MonthlyStatementAppendMoneyDataStr = MonthlyStatementAppendMoneyDataStr.Substring(0, MonthlyStatementAppendMoneyDataStr.Length - 1);
                                        }
                                        MonthlyStatementAppendMoneyDataStr = "\"MonthlyStatementAppendMoneyData\":[" + MonthlyStatementAppendMoneyDataStr + "]";
                                        #endregion

                                        MonthlyStatementDataJsonStr = "{\"MonthlyStatementDataJson\":{" + MonthlyStatementDataStr + "," + MonthlyStatementAppendDataStr + "," + MonthlyStatementAppendMoneyDataStr + "}}";
                                    }
                                    else
                                    {
                                        ms.sObjectID     = sObjectID;
                                        ms.sObjectType   = sObjectType;
                                        ms.sType         = sType;
                                        ms.sUpMoney      = sUpMoney;
                                        ms.sThisMoney    = sThisMoney;
                                        ms.sMoney        = sMoney;
                                        ms.sToMoney      = sToMoney;
                                        ms.sBalanceMoney = sBalanceMoney;
                                        //ms.sSteps = 0;
                                        ms.sBalanceType  = sBalanceType;
                                        ms.sReceiptState = sReceiptState;
                                        ms.sDateTime     = sDateTime;
                                        //ms.sState = 0;
                                        //ms.UserID = this.userid;
                                        //ms.sAppendTime = DateTime.Now;

                                        ms.MonthlyStatementDataJson = (MonthlyStatementDataJson)JavaScriptConvert.DeserializeObject(_MonthlyStatementDataJson, typeof(MonthlyStatementDataJson));

                                        try
                                        {
                                            MonthlyStatements.UpdateMonthlyStatementInfo(ms);

                                            MonthlyStatements.UpdateMonthlyStatementSteps(MonthlyStatementID, ms.sSteps);    //更新新单据步骤

                                            MonthlyStatementWorkingLogInfo mwl = new MonthlyStatementWorkingLogInfo();
                                            mwl.MonthlyStatementID = MonthlyStatementID;
                                            mwl.UserID             = this.userid;
                                            mwl.mType       = 1;
                                            mwl.mMsg        = MonthlyStatementWorkingLogMsg;
                                            mwl.mAppendTime = DateTime.Now;

                                            MonthlyStatements.AddMonthlyStatementWorkingLogInfo(mwl);

                                            AddMsgLine("对账单更新成功!");
                                            AddScript("window.setTimeout('location=location;',2000);");
                                        }catch (Exception ex)
                                        {
                                            AddErrLine("内部错误,请重试!" + ex.Message);
                                        }
                                    }
                                }
                                else
                                {
                                    AddErrLine("参数错误,请重试!");
                                }
                                break;

                                #endregion
                                #region 对账确认
                            case "1":
                            case "d":    //完成对账,对账确认
                                if (!ispost)
                                {
                                    try
                                    {
                                        ms = MonthlyStatements.GetMonthlyStatementInfoModel(MonthlyStatementID);
                                        if (ms != null)
                                        {
                                            if (ms.sSteps == 0)
                                            {
                                                MonthlyStatements.UpdateMonthlyStatementSteps(MonthlyStatementID, 1);

                                                MonthlyStatementWorkingLogInfo mwl = new MonthlyStatementWorkingLogInfo();
                                                mwl.MonthlyStatementID = MonthlyStatementID;
                                                mwl.UserID             = this.userid;
                                                mwl.mType       = 2;
                                                mwl.mMsg        = MonthlyStatementWorkingLogMsg;
                                                mwl.mAppendTime = DateTime.Now;

                                                MonthlyStatements.AddMonthlyStatementWorkingLogInfo(mwl);

                                                //获取下一张未对账确认对账单


                                                AddMsgLine("对账确认成功!");
                                            }
                                            else
                                            {
                                                AddErrLine("非新开对账单,无法进行对账确认操作,请重试!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误,请重试!");
                                        }
                                    }
                                    catch
                                    {
                                        AddErrLine("对账确认 操作失败!请重试!");
                                    }
                                }
                                break;

                                #endregion
                                #region 到款
                            case "2":
                            case "m":    //到款
                                if (!ispost)
                                {
                                    try
                                    {
                                        ms = MonthlyStatements.GetMonthlyStatementInfoModel(MonthlyStatementID);
                                        if (ms != null)
                                        {
                                            if (ms.sSteps == 1)
                                            {
                                                MonthlyStatements.UpdateMonthlyStatementSteps(MonthlyStatementID, 2);

                                                MonthlyStatementWorkingLogInfo mwl = new MonthlyStatementWorkingLogInfo();
                                                mwl.MonthlyStatementID = MonthlyStatementID;
                                                mwl.UserID             = this.userid;
                                                mwl.mType       = 3;
                                                mwl.mMsg        = MonthlyStatementWorkingLogMsg;
                                                mwl.mAppendTime = DateTime.Now;

                                                MonthlyStatements.AddMonthlyStatementWorkingLogInfo(mwl);

                                                AddMsgLine("到款 操作成功!");
                                            }
                                            else
                                            {
                                                AddErrLine("非已对账确认的对账单,无法进行到款操作,请重试!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误,请重试!");
                                        }
                                    }
                                    catch
                                    {
                                        AddErrLine("到款 操作失败!请重试!");
                                    }
                                }
                                break;

                                #endregion
                                #region 结账
                            case "3":
                            case "e":    //结账
                                if (!ispost)
                                {
                                    try
                                    {
                                        ms = MonthlyStatements.GetMonthlyStatementInfoModel(MonthlyStatementID);
                                        if (ms != null)
                                        {
                                            if (ms.sSteps == 2)
                                            {
                                                MonthlyStatements.UpdateMonthlyStatementSteps(MonthlyStatementID, 3);

                                                MonthlyStatementWorkingLogInfo mwl = new MonthlyStatementWorkingLogInfo();
                                                mwl.MonthlyStatementID = MonthlyStatementID;
                                                mwl.UserID             = this.userid;
                                                mwl.mType       = 4;
                                                mwl.mMsg        = MonthlyStatementWorkingLogMsg;
                                                mwl.mAppendTime = DateTime.Now;

                                                MonthlyStatements.AddMonthlyStatementWorkingLogInfo(mwl);

                                                AddMsgLine("结账 操作成功!");
                                            }
                                            else
                                            {
                                                AddErrLine("非已到款的对账单,无法进行结账操作,请重试!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误,请重试!");
                                        }
                                    }
                                    catch
                                    {
                                        AddErrLine("结账 操作失败!请重试!");
                                    }
                                }
                                break;

                                #endregion
                                #region 作废
                            case "i":
                                if (!ispost)
                                {
                                    try
                                    {
                                        ms = MonthlyStatements.GetMonthlyStatementInfoModel(MonthlyStatementID);
                                        if (ms != null)
                                        {
                                            if (ms.sSteps <= 1)
                                            {
                                                //更新对账单状态
                                                MonthlyStatements.UpdateMonthlyStatementState(MonthlyStatementID);
                                                MonthlyStatementWorkingLogInfo mwl = new MonthlyStatementWorkingLogInfo();
                                                mwl.MonthlyStatementID = MonthlyStatementID;
                                                mwl.UserID             = this.userid;
                                                mwl.mType       = -1;
                                                mwl.mMsg        = MonthlyStatementWorkingLogMsg;
                                                mwl.mAppendTime = DateTime.Now;

                                                MonthlyStatements.AddMonthlyStatementWorkingLogInfo(mwl);
                                                AddMsgLine("作废 操作成功!");
                                            }
                                            else
                                            {
                                                AddErrLine("到款后的对账单无法作废!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误,请重试!");
                                        }
                                    }
                                    catch
                                    {
                                        AddErrLine("作废 操作失败!请重试!");
                                    }
                                }
                                break;
                                #endregion
                            }
                        }

                        if (format == "json")
                        {
                            Response.ClearContent();
                            Response.Buffer          = true;
                            Response.ExpiresAbsolute = System.DateTime.Now.AddYears(-1);
                            Response.Expires         = 0;

                            Response.Charset         = "utf-8";
                            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                            Response.ContentType     = "application/json";
                            string Json_Str = "{\"results\": {\"msg\":\"" + this.msgbox_text + "\",\"state\":\"" + (!IsErr()).ToString() + "\",\"NextMonthlyStatementID\":\"" + NextMonthlyStatementID + "\"}}";
                            Response.Write(Json_Str);
                            Response.End();
                        }
                    }
                    else
                    {
                        AddErrLine("权限不足!");
                        AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                    }
                }
                else
                {
                    AddErrLine("参数错误!");
                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }
コード例 #2
0
        //public DataTable BankList = new DataTable();//银行列表

        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                /*
                 * CertificateDataJson cdj = new CertificateDataJson();
                 * CertificateDataInfo[] cdi = new CertificateDataInfo[1] ;
                 * cdi[0] = new CertificateDataInfo();
                 * cdi[0].cdAppendTime = DateTime.Now;
                 *
                 * cdj.CertificateDataInfoJson = cdi;
                 * CertificateDataJsonStr = JavaScriptConvert.SerializeObject(cdi);
                 */
                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-1") || CheckUserPopedoms("6-5-2") || CheckUserPopedoms("6-5-3") || CheckUserPopedoms("6-5-4"))
                {
                    Act       = HTTPRequest.GetString("Act");
                    OrderType = HTTPRequest.GetInt("OrderType", 0);
                    OrderID   = HTTPRequest.GetInt("OrderID", 0);
                    string NewPIC = Utils.ChkSQL(HTTPRequest.GetString("NewPIC"));
                    cCode  = Utils.ChkSQL(HTTPRequest.GetString("cCode"));
                    format = HTTPRequest.GetString("format");

                    #region 鉴权
                    if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-1") || CheckUserPopedoms("6-5-2") || CheckUserPopedoms("6-5-3") || CheckUserPopedoms("6-5-4") || CheckUserPopedoms("6-5-5") || CheckUserPopedoms("6-5-6"))
                    {
                        if (Act == "Add")
                        {
                            if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-1"))
                            {
                            }
                            else
                            {
                                AddErrLine("权限不足,无法新建 凭证 列表!");
                            }
                        }
                        if (Act == "Edit" || Act == "View")
                        {
                            if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-2") || CheckUserPopedoms("6-5-3"))
                            {
                            }
                            else
                            {
                                AddErrLine("权限不足,无法新建 凭证 列表!");
                            }
                        }
                        //作废
                        if (Act == "i")
                        {
                            if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-4"))
                            {
                            }
                            else
                            {
                                AddErrLine("权限不足,无法新建 凭证 列表!");
                            }
                        }
                        //审核
                        if (Act == "s")
                        {
                            if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-5"))
                            {
                            }
                            else
                            {
                                AddErrLine("权限不足,无法新建 凭证 列表!");
                            }
                        }
                    }
                    #endregion

                    if (!IsErr())
                    {
                        if (Act == "Edit")
                        {
                            CertificateID = Utils.StrToInt(HTTPRequest.GetString("cid"), 0);

                            ci        = Certificates.GetCertificateInfoModel(CertificateID);
                            cCode     = ci.cCode;
                            cDateTime = ci.cDateTime;
                            cNumber   = ci.cNumber;

                            IsVerify = ci.cSteps == 1;

                            if (IsVerify)
                            {
                                TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks);
                                TimeSpan ts2 = new TimeSpan(Certificates.GetLastVerifyTime(CertificateID).Ticks);
                                TimeSpan ts  = ts1.Subtract(ts2).Duration();

                                IsVerifyLongTime  = ts.TotalHours > 48;
                                IsVerifyLongTimeB = ts.TotalHours > 6;
                            }

                            DataTable cdList = Certificates.GetCertificateDataInfoList(" cd.CertificateID = " + CertificateID + " order by cd.CertificateDataID asc").Tables[0];
                            if (cdList != null)
                            {
                                foreach (DataRow dr in cdList.Rows)
                                {
                                    CertificateDataJsonStr += "{\"CertificateDataID\":\"" + dr["CertificateDataID"].ToString() + "\",\"CertificateID\":\"" + dr["CertificateID"].ToString() + "\",\"FeesSubjectName\":\"" + dr["FeesSubjectName"].ToString() + "\",\"FeesSubjectID\":\"" + dr["FeesSubjectID"].ToString() + "\",\"cdName\":\"" + dr["cdName"].ToString() + "\",\"cdMoney\":\"" + dr["cdMoney"].ToString() + "\",\"cdMoneyB\":\"" + dr["cdMoneyB"].ToString() + "\",\"cdRemake\":\"" + dr["cdRemake"].ToString() + "\",\"cdAppendTime\":\"" + dr["cdAppendTime"].ToString() + "\",\"toObject\":\"" + dr["toObject"].ToString() + "\",\"toObjectID\":\"" + dr["toObjectID"].ToString() + "\",\"ObjectName\":\"" + dr["ObjectName"].ToString() + "\"},";
                                }
                            }
                            if (CertificateDataJsonStr.Trim() != "")
                            {
                                CertificateDataJsonStr = "{\"CertificateDataInfoJson\":[" + Utils.ReSQLSetTxt(CertificateDataJsonStr.Trim()) + "]}";
                            }

                            PicList = Certificates.GetCertificatePicInfoList(" CertificateID=" + CertificateID + " order by cAppendTime desc").Tables[0];
                        }
                        if (ispost)
                        {
                            //string cCode = Utils.ChkSQL(HTTPRequest.GetString("cCode"));
                            decimal cMoney     = (HTTPRequest.GetString("cMoney").Trim() != "") ? Convert.ToDecimal(HTTPRequest.GetString("cMoney")) : 0;
                            int     cType      = HTTPRequest.GetInt("cType", 0);
                            int     UserID     = this.userid;
                            int     StaffID    = HTTPRequest.GetInt("StaffID", 0);
                            string  cRemake    = HTTPRequest.GetString("cRemake");
                            int     toObject   = HTTPRequest.GetInt("toObject", 0);
                            int     toObjectID = HTTPRequest.GetInt("toObjectID", 0);
                            int     cObject    = HTTPRequest.GetInt("cObject", 0);
                            int     cObjectID  = HTTPRequest.GetInt("cObjectID", 0);
                            int     cState     = HTTPRequest.GetInt("cState", 0);
                            int     BankID     = HTTPRequest.GetInt("BankID", 0);
                            cNumber = HTTPRequest.GetInt("cNumber", 0);

                            cDateTime = (HTTPRequest.GetString("cDateTime").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("cDateTime")) : DateTime.Now;

                            string CertificateDataStr = Utils.ChkSQL(HTTPRequest.GetString("CertificateDataStr"));


                            ci.cMoney     = cMoney;
                            ci.cType      = cType;
                            ci.StaffID    = StaffID;
                            ci.cRemake    = cRemake;
                            ci.toObject   = toObject;
                            ci.toObjectID = toObjectID;
                            ci.cObject    = cObject;
                            ci.cObjectID  = cObjectID;
                            ci.cState     = cState;
                            ci.cDateTime  = cDateTime;
                            ci.BankID     = BankID;


                            ci.CertificateDataJson = (CertificateDataJson)JavaScriptConvert.DeserializeObject(CertificateDataStr, typeof(CertificateDataJson));

                            if (Act == "Add")
                            {
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-1"))
                                {
                                    ci.cSteps      = 0;
                                    ci.UserID      = UserID;
                                    ci.cAppendTime = DateTime.Now;
                                    ci.cCode       = Certificates.GetNewNum(); //cCode;//

                                    ci.cNumber = cNumber;
                                    if (!Certificates.CheckCertificateNumber(ci.cDateTime, ci.cNumber))
                                    {
                                        if (!Certificates.ExistsCertificateInfo(ci.cCode))
                                        {
                                            CertificateID = Certificates.AddCertificateInfo(ci);

                                            //添加凭证照片
                                            AddPic(NewPIC, CertificateID);

                                            CertificateWorkingLogInfo co = new CertificateWorkingLogInfo();
                                            co.CertificateID = CertificateID;
                                            co.UserID        = this.userid;
                                            co.cType         = 0;
                                            co.cAppendTime   = DateTime.Now;
                                            Certificates.AddCertificateWorkingLog(co);

                                            AddMsgLine("凭证录入成功!");
                                            AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                        }
                                        else
                                        {
                                            AddErrLine("凭证编号重复,系统已存在该编号(" + ci.cCode + ")!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("凭证序号重复,系统已存在该序号(" + ci.cDateTime.ToString("yyyyMMdd") + "-" + (ci.cNumber.ToString()).PadLeft(config.CertificateCodeLen, '0') + ")!");
                                    }
                                }
                                else
                                {
                                    AddErrLine("权限不足!");
                                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                }
                            }
                            if (Act == "Edit")
                            {
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-3"))
                                {
                                    if (ci.cNumber != cNumber)
                                    {
                                        if (!Certificates.CheckCertificateNumber(ci.cDateTime, cNumber))
                                        {
                                            ci.cNumber = cNumber;
                                        }
                                        else
                                        {
                                            AddErrLine("凭证序号重复,系统已存在该序号(" + ci.cDateTime.ToString("yyyyMMdd") + "-" + (cNumber.ToString()).PadLeft(config.CertificateCodeLen, '0') + ")!");
                                        }
                                    }

                                    if (!IsErr())
                                    {
                                        Certificates.UpdateCertificateInfo(ci);
                                        //添加凭证照片
                                        AddPic(NewPIC, CertificateID);

                                        CertificateWorkingLogInfo co = new CertificateWorkingLogInfo();
                                        co.CertificateID = CertificateID;
                                        co.UserID        = this.userid;
                                        co.cType         = 1;
                                        co.cAppendTime   = DateTime.Now;
                                        Certificates.AddCertificateWorkingLog(co);

                                        AddMsgLine("凭证 " + ci.cDateTime.ToString("yyyyMMdd") + "-" + (ci.cNumber.ToString()).PadLeft(config.CertificateCodeLen, '0') + " 修改成功!");
                                        AddScript("window.setTimeout('location=\"/certificate_do-Edit-" + OrderType + "-" + OrderID + "-" + CertificateID + ".aspx\";',1000);");
                                    }
                                }
                                else
                                {
                                    AddErrLine("权限不足!");
                                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                }
                            }
                        }
                        else
                        {
                            if (format != "json")
                            {
                                //BankList = tbBankInfo.GetBankList("").Tables[0];
                                StaffList = Caches.GetDepartmentsClassInfoAndStaffListToHTML();
                                //FeesSubjectClassList = Caches.GetFeesSubjectClassInfoToHTML();
                                //string CustomersList = Caches.GetCustomersClassInfoAndDataToHTML();//客户
                                //string SupplierList = Caches.GetSupplierClassInfoAndDataToHTML();//供应商
                                //ToObjectList = "<ul><li rel=\"cus\">客户" + CustomersList + "</li>"+
                                //                        "<li rel=\"sup\">供应商" + SupplierList + "</li>" +
                                //                        "<li rel=\"sta\">人员" + StaffList + "</li>" +
                                //                        "</ul>";

                                DepartmentsJson = Caches.GetDepartmentsClassInfoToJson(-1, true, true);
                                SupplierJson    = Caches.GetSupplierClassInfoToJson(-1, true, true);
                                CustomersJson   = Caches.GetCustomersClassInfoToJson(-1, true, true);
                                FeesSubjectJson = Caches.GetFeesSubjectClassInfoToJson(-1, false, true);

                                PaymentSystemJson = Caches.GetPaymentSystemJson();
                            }
                            if (Act == "Add")
                            {
                                cCode   = "";// Certificates.GetNewNum();
                                cNumber = Certificates.GetCertificateNewNumber(cDateTime);
                            }
                            if (Act == "GetNum")
                            {
                                CertificateID = Utils.StrToInt(HTTPRequest.GetString("cid"), 0);
                                cDateTime     = (HTTPRequest.GetString("cDateTime").Trim() != "") ? Convert.ToDateTime(HTTPRequest.GetString("cDateTime")) : DateTime.Now;
                                cNumber       = Certificates.GetCertificateNewNumber(cDateTime);
                                tJson         = ",\"MaxOrderDate\":\"" + Certificates.GetMaxCertificateData(CertificateID) + "\",\"Num\":" + cNumber;
                            }
                            //作废
                            if (Act == "i")
                            {
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-4"))
                                {
                                    CertificateID = Utils.StrToInt(HTTPRequest.GetString("cid"), 0);

                                    if (CertificateID > 0)
                                    {
                                        ci = Certificates.GetCertificateInfoModel(CertificateID);
                                        if (ci != null)
                                        {
                                            ci.cState = 1;
                                            Certificates.UpdateCertificateInfo(ci);

                                            CertificateWorkingLogInfo co = new CertificateWorkingLogInfo();
                                            co.CertificateID = CertificateID;
                                            co.UserID        = this.userid;
                                            co.cType         = -1;
                                            co.cAppendTime   = DateTime.Now;
                                            Certificates.AddCertificateWorkingLog(co);

                                            AddMsgLine("凭证 " + ci.cDateTime.ToString("yyyyMMdd") + "-" + (ci.cNumber.ToString()).PadLeft(config.CertificateCodeLen, '0') + " 作废成功!");
                                        }
                                        else
                                        {
                                            AddErrLine("凭证不存在!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("参数错误!");
                                    }
                                }
                                else
                                {
                                    AddErrLine("权限不足!");
                                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                                }
                            }
                            //审核
                            if (Act == "s")
                            {
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-5"))
                                {
                                    CertificateID = Utils.StrToInt(HTTPRequest.GetString("cid"), 0);
                                    if (CertificateID > 0)
                                    {
                                        ci = Certificates.GetCertificateInfoModel(CertificateID);
                                        if (ci != null)
                                        {
                                            Certificates.SetCertificateSteps(CertificateID, 1);

                                            CertificateWorkingLogInfo co = new CertificateWorkingLogInfo();
                                            co.CertificateID = CertificateID;
                                            co.UserID        = this.userid;
                                            co.cType         = 2;
                                            co.cAppendTime   = DateTime.Now;
                                            Certificates.AddCertificateWorkingLog(co);

                                            AddMsgLine("凭证 " + ci.cDateTime.ToString("yyyyMMdd") + "-" + (ci.cNumber.ToString()).PadLeft(config.CertificateCodeLen, '0') + " 审核成功!");
                                        }
                                        else
                                        {
                                            AddErrLine("凭证不存在!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("参数错误!");
                                    }
                                }
                                else
                                {
                                    AddErrLine("权限不足!");
                                }
                            }
                            //撤回重审
                            if (Act == "rs")
                            {
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-7") || CheckUserPopedoms("6-5-8"))
                                {
                                    CertificateID = Utils.StrToInt(HTTPRequest.GetString("cid"), 0);
                                    if (CertificateID > 0)
                                    {
                                        ci = Certificates.GetCertificateInfoModel(CertificateID);
                                        if (ci != null)
                                        {
                                            Certificates.SetCertificateSteps(CertificateID, 0);

                                            CertificateWorkingLogInfo co = new CertificateWorkingLogInfo();
                                            co.CertificateID = CertificateID;
                                            co.UserID        = this.userid;
                                            co.cType         = 4;
                                            co.cAppendTime   = DateTime.Now;
                                            Certificates.AddCertificateWorkingLog(co);

                                            AddMsgLine("凭证 " + ci.cDateTime.ToString("yyyyMMdd") + "-" + (ci.cNumber.ToString()).PadLeft(config.CertificateCodeLen, '0') + " 撤回成功!");
                                        }
                                        else
                                        {
                                            AddErrLine("凭证不存在!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("参数错误!");
                                    }
                                }
                                else
                                {
                                    AddErrLine("权限不足!");
                                }
                            }
                            //获取指定凭证前后两个凭证信息
                            if (Act == "p")
                            {
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("6-5-2"))
                                {
                                    CertificateID = Utils.StrToInt(HTTPRequest.GetString("cid"), 0);
                                    if (CertificateID > 0)
                                    {
                                        long[] UpDownID = Certificates.GetCertificateUpDownID(CertificateID);
                                        tJson = ",\"UpDownID\":{\"UpID\":\"" + UpDownID[0] + "\",\"DownID\":\"" + UpDownID[1] + "\"}";
                                    }
                                    else
                                    {
                                        AddErrLine("参数错误!");
                                    }
                                }
                                else
                                {
                                    AddErrLine("权限不足!");
                                }
                            }
                        }
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
            if (format == "json")
            {
                Response.ClearContent();
                Response.Buffer          = true;
                Response.ExpiresAbsolute = System.DateTime.Now.AddYears(-1);
                Response.Expires         = 0;

                Response.Charset         = "utf-8";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                Response.ContentType     = "application/json";
                string Json_Str = "{\"results\": {\"msg\":\"" + this.msgbox_text + "\",\"state\":\"" + (!IsErr()).ToString() + "\"" + tJson + "}}";
                Response.Write(Json_Str);
                Response.End();
            }
        }