public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            string refNo = context.Request.QueryString["refno"];

            int receiptType = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["type"]) || !int.TryParse(context.Request.QueryString["type"], out receiptType))
                receiptType = 0;

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.WareHouse.BLL.StockReceiptBLL bll = new NFMT.WareHouse.BLL.StockReceiptBLL();
            NFMT.Common.SelectModel select = bll.GetStockReceiptUpdateListSelectModel(pageIndex, pageSize, orderStr, refNo, receiptType);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                switch (sortDataField)
                {
                    case "RefNo":
                        sortDataField = "sn.RefNo";
                        break;
                    case "StockWeight":
                        sortDataField = "sto.NetAmount";
                        break;
                    case "StockStatusName":
                        sortDataField = "sto.StockStatus";
                        break;
                    case "CorpName":
                        sortDataField = "cor.CorpName";
                        break;
                    case "AssetName":
                        sortDataField = "ass.AssetName ";
                        break;
                    case "BrandName":
                        sortDataField = "bra.BrandName";
                        break;
                    case "DetailId":
                        sortDataField = "sod.DetailId";
                        break;
                    case "ReceiptWeight":
                        sortDataField = "sr.SumAmount";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            int subId = 0;
            int receiptId = 0;

            if (string.IsNullOrEmpty(context.Request.QueryString["si"]) || !int.TryParse(context.Request.QueryString["si"], out subId))
                subId = 0;

            if (string.IsNullOrEmpty(context.Request.QueryString["ri"]) || !int.TryParse(context.Request.QueryString["ri"], out receiptId))
                receiptId = 0;

            string sids = context.Request.QueryString["sids"];
            if (string.IsNullOrEmpty(sids))
                sids = "0";

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.WareHouse.BLL.StockReceiptBLL bll = new NFMT.WareHouse.BLL.StockReceiptBLL();

            NFMT.Common.SelectModel select = bll.GetReceiptingStockListSelect(pageIndex, pageSize, orderStr, subId, receiptId, sids);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string redirectUrl = "StockReceiptList.aspx";

            if (!IsPostBack)
            {
                Utility.VerificationUtility ver = new Utility.VerificationUtility();
                ver.JudgeOperate(this.Page, 88, new List<NFMT.Common.OperateEnum>() { NFMT.Common.OperateEnum.提交审核, NFMT.Common.OperateEnum.作废, NFMT.Common.OperateEnum.撤返, NFMT.Common.OperateEnum.执行完成, NFMT.Common.OperateEnum.执行完成撤销 });

                NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
                NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

                //获取仓库回执
                int receiptId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out receiptId))
                    Response.Redirect(redirectUrl);

                NFMT.WareHouse.BLL.StockReceiptBLL receiptBLL = new NFMT.WareHouse.BLL.StockReceiptBLL();
                result = receiptBLL.Get(user, receiptId);

                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.WareHouse.Model.StockReceipt stockReceipt = result.ReturnValue as NFMT.WareHouse.Model.StockReceipt;
                if (stockReceipt == null || stockReceipt.ReceiptId <= 0)
                    Response.Redirect(redirectUrl);

                this.curStockReceipt = stockReceipt;

                //获取合约与子合约
                NFMT.Contract.BLL.ContractSubBLL subBLL = new NFMT.Contract.BLL.ContractSubBLL();
                result = subBLL.Get(user, stockReceipt.ContractSubId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                if (sub == null || sub.SubId <= 0)
                    Response.Redirect(redirectUrl);

                this.curContractSub = sub;

                NFMT.Contract.BLL.ContractBLL conBLL = new NFMT.Contract.BLL.ContractBLL();
                result = conBLL.Get(user, sub.ContractId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                //主合约
                NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                if (contract == null || contract.ContractId <= 0)
                    Response.Redirect(redirectUrl);

                this.curContract = contract;

                this.contractExpander1.CurContract = contract;
                this.contractExpander1.CurContractSub = sub;
                this.contractExpander1.RedirectUrl = redirectUrl;

                this.navigation1.Routes.Add("回执列表", redirectUrl);
                this.navigation1.Routes.Add("回执明细", string.Empty);

                string sids = "0";
                //获取回执明细
                NFMT.WareHouse.BLL.StockReceiptDetailBLL detailBLL = new NFMT.WareHouse.BLL.StockReceiptDetailBLL();
                result = detailBLL.Load(user, stockReceipt.ReceiptId,NFMT.Common.StatusEnum.已作废);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);
                List<NFMT.WareHouse.Model.StockReceiptDetail> details = result.ReturnValue as List<NFMT.WareHouse.Model.StockReceiptDetail>;
                if (details == null)
                    Response.Redirect(redirectUrl);

                if (details.Count > 0)
                    sids = string.Empty;
                for (int i = 0; i < details.Count; i++)
                {
                    NFMT.WareHouse.Model.StockReceiptDetail detail = details[i];
                    sids += detail.StockLogId.ToString();
                    if (i < details.Count - 1)
                        sids += ",";
                }

                NFMT.Common.SelectModel select = receiptBLL.GetReceiptingStockListSelect(1, 100, "sto.StockId desc", sub.SubId, receiptId, sids);
                result = receiptBLL.Load(user, select);
                int totalRows = result.AffectCount;
                System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
                this.curReceiptingJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());

                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                string json = serializer.Serialize(stockReceipt);
                this.hidModel.Value = json;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            DateTime startDate = NFMT.Common.DefaultValue.DefaultTime;
            DateTime endDate = NFMT.Common.DefaultValue.DefaultTime;

            string refNo = context.Request.QueryString["refNo"];

            int assetId = 0;
            if (string.IsNullOrEmpty(context.Request.QueryString["ass"]) || !int.TryParse(context.Request.QueryString["ass"], out assetId))
                assetId = 0;

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                switch (sortDataField)
                {
                    case "RefId":
                        sortDataField = "sis.RefId";
                        break;
                    case "AssetName":
                        sortDataField = "ass.AssetName";
                        break;
                    case "RefNo":
                        sortDataField = "sn.RefNo";
                        break;
                    case "PaperNo":
                        sortDataField = "st.PaperNo";
                        break;
                    case "CardNo":
                        sortDataField = "st.CardNo";
                        break;
                    case "StockDate":
                        sortDataField = "st.StockDate";
                        break;
                    case "OutContractNo":
                        sortDataField = "sub.OutContractNo";
                        break;
                    case "InCorpName":
                        sortDataField = "inCorp.CorpName";
                        break;
                    case "OutCorpName":
                        sortDataField = "outCorp.CorpName";
                        break;
                    case "MUName":
                        sortDataField = "mu.MUName";
                        break;
                    case "inGapAmount":
                        sortDataField = "inLog.GapAmount";
                        break;
                    case "inNetAmount":
                    case "ReceiptInGap":
                    case "inRate":
                        sortDataField = "inLog.NetAmount";
                        break;
                    case "outNetAmount":
                        sortDataField = "outLog.NetAmount";
                        break;
                    case "outGapAmount":
                        sortDataField = "outLog.GapAmount";
                        break;
                    case "outRate":
                    case "ReceiptOutGap":
                    case "ProfitOrLoss":
                        sortDataField = "outLog.ReceiptOutGap";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.WareHouse.BLL.StockReceiptBLL bll = new NFMT.WareHouse.BLL.StockReceiptBLL();
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = bll.GetReceiptReportSelect(pageIndex, pageSize, orderStr, assetId, refNo);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
            Dictionary<string, object> dic = new Dictionary<string, object>();

            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string redirectUrl = "StockReceiptList.aspx";

            if (!IsPostBack)
            {
                Utility.VerificationUtility ver = new Utility.VerificationUtility();
                ver.JudgeOperate(this.Page, 88, new List<NFMT.Common.OperateEnum>() { NFMT.Common.OperateEnum.录入 });

                NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
                NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

                //获取合约与子合约
                int subId = 0;
                if (string.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out subId))
                    Response.Redirect(redirectUrl);

                NFMT.Contract.BLL.ContractSubBLL subBLL = new NFMT.Contract.BLL.ContractSubBLL();
                result = subBLL.Get(user, subId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                if (sub == null || sub.SubId <= 0)
                    Response.Redirect(redirectUrl);

                this.curContractSub = sub;

                //合约币种
                NFMT.Data.Model.Currency currency = NFMT.Data.BasicDataProvider.Currencies.FirstOrDefault(temp => temp.CurrencyId == sub.SettleCurrency);
                if (currency != null && currency.CurrencyId > 0)
                    this.currencyName = currency.CurrencyName;
                //合约计量单位
                NFMT.Data.Model.MeasureUnit mu = NFMT.Data.BasicDataProvider.MeasureUnits.FirstOrDefault(temp => temp.MUId == sub.UnitId);
                if (mu != null && mu.MUId > 0)
                    this.MUName = mu.MUName;

                NFMT.Contract.BLL.ContractBLL conBLL = new NFMT.Contract.BLL.ContractBLL();
                result = conBLL.Get(user, sub.ContractId);
                if (result.ResultStatus != 0)
                    Response.Redirect(redirectUrl);

                //主合约
                NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                if (contract == null || contract.ContractId <= 0)
                    Response.Redirect(redirectUrl);

                this.curContract = contract;

                this.contractExpander1.CurContract = contract;
                this.contractExpander1.CurContractSub = sub;
                this.contractExpander1.RedirectUrl = redirectUrl;

                this.navigation1.Routes.Add("回执列表", redirectUrl);
                this.navigation1.Routes.Add("合约列表", "StockReceiptContractList.aspx");
                this.navigation1.Routes.Add("回执新增", string.Empty);

                tradeDirString = ((NFMT.Contract.TradeDirectionEnum)contract.TradeDirection).ToString();

                //ReceiptingStockList Json
                NFMT.WareHouse.BLL.StockReceiptBLL bll = new NFMT.WareHouse.BLL.StockReceiptBLL();

                int receiptId = 0;
                string sids = "0";
                NFMT.Common.SelectModel select = bll.GetReceiptingStockListSelect(1, 100, "sto.StockId desc", sub.SubId, receiptId, sids);
                result = bll.Load(user, select);
                int totalRows = result.AffectCount;
                System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
                this.curReceiptingJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());

            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            string contractCode = context.Request.QueryString["cc"];
            DateTime fromDate = NFMT.Common.DefaultValue.DefaultTime;
            DateTime toDate = NFMT.Common.DefaultValue.DefaultTime;
            int status = 0;

            if (!string.IsNullOrEmpty(context.Request["s"]))
                int.TryParse(context.Request["s"], out status);
            if (!string.IsNullOrEmpty(context.Request.QueryString["fd"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["fd"], out fromDate))
                    fromDate = NFMT.Common.DefaultValue.DefaultTime;
            }
            if (!string.IsNullOrEmpty(context.Request.QueryString["td"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["td"], out toDate))
                    toDate = NFMT.Common.DefaultValue.DefaultTime;
                else
                    toDate = toDate.AddDays(1);
            }

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                switch (sortDataField)
                {
                    case "ReceiptDate":
                        sortDataField = "sr.ReceiptDate";
                        break;
                    case "SubNo":
                        sortDataField = "cs.SubNo";
                        break;
                    case "ReceipterName":
                        sortDataField = "emp.Name";
                        break;
                    case "ReceiptTypeName":
                        sortDataField = "sr.ReceiptType";
                        break;
                    case "StatusName":
                        sortDataField = "sr.ReceiptStatus";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.WareHouse.BLL.StockReceiptBLL bll = new NFMT.WareHouse.BLL.StockReceiptBLL();
            NFMT.Common.SelectModel select = bll.GetSelectModel(pageIndex, pageSize, orderStr, contractCode, fromDate, toDate, status);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }
        public void ProcessRequest(HttpContext context)
        {
            int pageIndex = 1, pageSize = 10;
            string orderStr = string.Empty, whereStr = string.Empty;

            string subNo = context.Request.QueryString["sn"];
            DateTime fromDate = NFMT.Common.DefaultValue.DefaultTime;
            DateTime toDate = NFMT.Common.DefaultValue.DefaultTime;
            int outCorpId = 0;

            if (!string.IsNullOrEmpty(context.Request.QueryString["oci"]))
            {
                if (!int.TryParse(context.Request.QueryString["oci"], out outCorpId))
                    outCorpId = 0;
            }

            if (!string.IsNullOrEmpty(context.Request.QueryString["fd"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["fd"], out fromDate))
                    fromDate = NFMT.Common.DefaultValue.DefaultTime;
            }
            if (!string.IsNullOrEmpty(context.Request.QueryString["td"]))
            {
                if (!DateTime.TryParse(context.Request.QueryString["td"], out toDate))
                    toDate = NFMT.Common.DefaultValue.DefaultTime;
            }

            int tradeDir = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["dir"]))
                int.TryParse(context.Request.QueryString["dir"], out tradeDir);

            if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
                int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
            pageIndex++;
            if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
                int.TryParse(context.Request.QueryString["pagesize"], out pageSize);

            if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
            {
                string sortDataField = context.Request.QueryString["sortdatafield"].Trim();
                string sortOrder = context.Request.QueryString["sortorder"].Trim();

                switch (sortDataField)
                {
                    case "ContractDate":
                        sortDataField = string.Format("cs.{0}", sortDataField);
                        break;
                    case "ContractNo":
                        sortDataField = string.Format("c.{0}", sortDataField);
                        break;
                    case "SubNo":
                        sortDataField = "cs.SubNo";
                        break;
                    case "InCorpName":
                        sortDataField = "inCorp.CorpName";
                        break;
                    case "OutCorpName":
                        sortDataField = "outCorp.CorpName";
                        break;
                    case "AssetName":
                        sortDataField = "a.AssetName";
                        break;
                    case "SignWeight":
                        sortDataField = "cs.SignAmount";
                        break;
                    case "SumWeight":
                        sortDataField = "sr.SumAmount";
                        break;
                    case "StatusName":
                        sortDataField = "sd.StatusName";
                        break;
                    case "OutContractNo":
                        sortDataField = "cs.OutContractNo";
                        break;
                }
                orderStr = string.Format("{0} {1}", sortDataField, sortOrder);
            }
            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;

            NFMT.WareHouse.BLL.StockReceiptBLL bll = new NFMT.WareHouse.BLL.StockReceiptBLL();
            NFMT.Common.SelectModel select = bll.GetContractListSelect(pageIndex, pageSize, orderStr, subNo, outCorpId, fromDate, toDate, tradeDir);
            NFMT.Authority.ContractAuth auth = new NFMT.Authority.ContractAuth();
            NFMT.Common.ResultModel result = bll.Load(user, select,auth);

            context.Response.ContentType = "text/plain";
            if (result.ResultStatus != 0)
            {
                context.Response.Write(result.Message);
                context.Response.End();
            }

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("count", totalRows);
            dic.Add("data", dt);

            string postData = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            context.Response.Write(postData);
        }