Exemple #1
0
        public void upload_fhd(WebHelper w, Dictionary <string, object> kv)
        {
            if (ExistsKeys(kv, "branch_no", "sale_master", "sale_detail", "pay_data") == false)
            {
                throw new Exception("参数错误");
            }
            var branch_no = w.Read("branch_no");
            var json      = w.Read("sale_master");

            ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json);
            var lst1 = new List <Model.sm_t_salesheet>();

            if (read.Read("datas") != null)
            {
                foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                {
                    var ord = new Model.sm_t_salesheet();
                    ord.sheet_no     = r.Read("sheet_no");
                    ord.voucher_no   = "";
                    ord.branch_no    = r.Read("branch_no");
                    ord.cust_no      = r.Read("cust_no");
                    ord.pay_way      = r.Read("pay_way");
                    ord.discount     = Conv.ToDecimal(r.Read("discount"));
                    ord.coin_no      = r.Read("coin_no");
                    ord.real_amount  = Conv.ToDecimal(r.Read("total_amount"));
                    ord.total_amount = Conv.ToDecimal(r.Read("total_amount"));
                    ord.paid_amount  = Conv.ToDecimal(r.Read("paid_amount"));
                    ord.approve_flag = "0";
                    ord.source_flag  = "";
                    ord.oper_id      = r.Read("oper_id");
                    ord.sale_man     = r.Read("sale_man");
                    ord.oper_date    = Conv.ToDateTime(r.Read("oper_date"));
                    ord.pay_date     = Conv.ToDateTime(r.Read("pay_date"));
                    ord.other1       = "";
                    ord.other2       = "";
                    ord.other3       = "";
                    ord.cm_branch    = "";
                    ord.approve_man  = "";
                    ord.approve_date = DateTime.MinValue;
                    ord.num1         = 0m;
                    ord.num2         = 0m;
                    ord.num3         = 0m;
                    ord.payfee_memo  = "";
                    ord.old_no       = "";
                    ord.psheet_no    = "";
                    ord.pay_nowmark  = "";
                    ord.if_back      = "";
                    ord.cust_cls     = "";
                    ord.other4       = "";
                    lst1.Add(ord);
                }
            }

            json = w.Read("sale_detail");
            read = new ReadWriteContext.ReadContextByJson(json);
            var lst2 = new List <Model.sm_t_salesheet_detail>();

            if (read.Read("datas") != null)
            {
                foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                {
                    var item = new Model.sm_t_salesheet_detail();
                    item.sheet_no    = r.Read("sheet_no");
                    item.item_no     = r.Read("item_no");
                    item.item_name   = r.Read("item_name");
                    item.unit_no     = r.Read("unit_no");
                    item.unit_factor = 1m;
                    item.sale_qnty   = Conv.ToDecimal(r.Read("sale_qnty"));
                    item.sale_price  = Conv.ToDecimal(r.Read("sale_price"));
                    item.real_price  = Conv.ToDecimal(r.Read("real_price"));
                    item.cost_price  = Conv.ToDecimal(r.Read("cost_price"));
                    item.sale_money  = Conv.ToDecimal(r.Read("sale_money"));
                    item.sale_tax    = 0m;
                    item.is_tax      = "0";
                    item.other1      = "";
                    item.other2      = "";
                    item.other3      = "";
                    item.other4      = "";
                    item.num1        = 0m;
                    item.num2        = 0m;
                    item.num3        = 0m;
                    item.num4        = 0m;
                    item.num5        = 0m;
                    item.num6        = 0m;
                    item.barcode     = r.Read("barcode");
                    item.sheet_sort  = Conv.ToInt(r.Read("sheet_sort"));
                    item.ret_qnty    = 0m;
                    item.discount    = 0m;
                    item.voucher_no  = "";
                    item.cost_notax  = 0m;
                    item.packqty     = 0;
                    item.sgqty       = 0m;
                    item.branch_no_d = "";
                    item.ly_sup_no   = "";
                    item.ly_rate     = 0m;
                    item.num7        = 0m;
                    item.other5      = "";
                    item.num8        = 0m;
                    item.produce_day = DateTime.MinValue;
                    lst2.Add(item);
                }
            }
            json = w.Read("pay_data");
            read = new ReadWriteContext.ReadContextByJson(json);
            var lst3 = new List <Model.ot_pay_flow>();

            if (read.Read("datas") != null)
            {
                foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                {
                    var item = new Model.ot_pay_flow();
                    item.sheet_no    = r.Read("sheet_no");
                    item.flow_id     = Conv.ToInt(r.Read("flow_id"));
                    item.cus_no      = r.Read("cus_no");
                    item.oper_id     = r.Read("oper_id");
                    item.oper_date   = Conv.ToDateTime(r.Read("oper_date"));
                    item.pay_way     = r.Read("pay_way");
                    item.sale_amount = Conv.ToDecimal(r.Read("sale_amount"));
                    item.pay_amount  = Conv.ToDecimal(r.Read("pay_amount"));
                    item.old_amount  = Conv.ToDecimal(r.Read("old_amount"));
                    item.ml          = Conv.ToDecimal(r.Read("ml"));
                    item.jh          = r.Read("jh");
                    item.remark      = r.Read("remark");
                    lst3.Add(item);
                }
            }
            if (lst1.Count > 0 || lst2.Count > 0)
            {
                bll.WriteFHD(lst1, lst2, lst3);
            }
        }
Exemple #2
0
        void IServiceBase.Request(string t, string pars, out string res)
        {
            try
            {
                ReadWriteContext.IReadContext rm = new ReadWriteContext.ReadContextByJson(pars);
                var          kv  = rm.ToDictionary();
                IBLL.ISettle bll = new BLL.Settle();
                if (t == "upload_fhd")
                {
                    if (CommonHelper.ExistsKeys(kv, "branch_no", "sale_master", "sale_detail", "pay_data") == false)
                    {
                        throw new Exception("参数错误");
                    }
                    var branch_no = rm.Read("branch_no");
                    var json      = rm.Read("sale_master");
                    ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json);
                    var lst1 = new List <Model.sm_t_salesheet>();
                    if (read.Read("datas") != null)
                    {
                        foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                        {
                            var ord = new Model.sm_t_salesheet();
                            ord.sheet_no     = r.Read("sheet_no");
                            ord.voucher_no   = "";
                            ord.branch_no    = r.Read("branch_no");
                            ord.cust_no      = r.Read("cust_no");
                            ord.pay_way      = r.Read("pay_way");
                            ord.discount     = Conv.ToDecimal(r.Read("discount"));
                            ord.coin_no      = r.Read("coin_no");
                            ord.real_amount  = Conv.ToDecimal(r.Read("total_amount"));
                            ord.total_amount = Conv.ToDecimal(r.Read("total_amount"));
                            ord.paid_amount  = Conv.ToDecimal(r.Read("paid_amount"));
                            ord.approve_flag = "0";
                            ord.source_flag  = "";
                            ord.oper_id      = r.Read("oper_id");
                            ord.sale_man     = r.Read("sale_man");
                            ord.oper_date    = Conv.ToDateTime(r.Read("oper_date"));
                            ord.pay_date     = Conv.ToDateTime(r.Read("pay_date"));
                            ord.other1       = "";
                            ord.other2       = "";
                            ord.other3       = "";
                            ord.cm_branch    = "";
                            ord.approve_man  = "";
                            ord.approve_date = DateTime.MinValue;
                            ord.num1         = 0m;
                            ord.num2         = 0m;
                            ord.num3         = 0m;
                            ord.payfee_memo  = "";
                            ord.old_no       = "";
                            ord.psheet_no    = "";
                            ord.pay_nowmark  = "";
                            ord.if_back      = "";
                            ord.cust_cls     = "";
                            ord.other4       = "";
                            lst1.Add(ord);
                        }
                    }

                    json = rm.Read("sale_detail");
                    read = new ReadWriteContext.ReadContextByJson(json);
                    var lst2 = new List <Model.sm_t_salesheet_detail>();
                    if (read.Read("datas") != null)
                    {
                        foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                        {
                            var item = new Model.sm_t_salesheet_detail();
                            item.sheet_no    = r.Read("sheet_no");
                            item.item_no     = r.Read("item_no");
                            item.item_name   = r.Read("item_name");
                            item.unit_no     = r.Read("unit_no");
                            item.unit_factor = 1m;
                            item.sale_qnty   = Conv.ToDecimal(r.Read("sale_qnty"));
                            item.sale_price  = Conv.ToDecimal(r.Read("sale_price"));
                            item.real_price  = Conv.ToDecimal(r.Read("real_price"));
                            item.cost_price  = Conv.ToDecimal(r.Read("cost_price"));
                            item.sale_money  = Conv.ToDecimal(r.Read("sale_money"));
                            item.sale_tax    = 0m;
                            item.is_tax      = "0";
                            item.other1      = "";
                            item.other2      = "";
                            item.other3      = "";
                            item.other4      = "";
                            item.num1        = 0m;
                            item.num2        = 0m;
                            item.num3        = 0m;
                            item.num4        = 0m;
                            item.num5        = 0m;
                            item.num6        = 0m;
                            item.barcode     = r.Read("barcode");
                            item.sheet_sort  = Conv.ToInt(r.Read("sheet_sort"));
                            item.ret_qnty    = 0m;
                            item.discount    = 0m;
                            item.voucher_no  = "";
                            item.cost_notax  = 0m;
                            item.packqty     = 0;
                            item.sgqty       = 0m;
                            item.branch_no_d = "";
                            item.ly_sup_no   = "";
                            item.ly_rate     = 0m;
                            item.num7        = 0m;
                            item.other5      = "";
                            item.num8        = 0m;
                            item.produce_day = DateTime.MinValue;
                            lst2.Add(item);
                        }
                    }
                    json = rm.Read("pay_data");
                    read = new ReadWriteContext.ReadContextByJson(json);
                    var lst3 = new List <Model.ot_pay_flow>();
                    if (read.Read("datas") != null)
                    {
                        foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                        {
                            var item = new Model.ot_pay_flow();
                            item.sheet_no    = r.Read("sheet_no");
                            item.flow_id     = Conv.ToInt(r.Read("flow_id"));
                            item.cus_no      = r.Read("cus_no");
                            item.oper_id     = r.Read("oper_id");
                            item.oper_date   = Conv.ToDateTime(r.Read("oper_date"));
                            item.pay_way     = r.Read("pay_way");
                            item.sale_amount = Conv.ToDecimal(r.Read("sale_amount"));
                            item.pay_amount  = Conv.ToDecimal(r.Read("pay_amount"));
                            item.old_amount  = Conv.ToDecimal(r.Read("old_amount"));
                            item.ml          = Conv.ToDecimal(r.Read("ml"));
                            item.jh          = r.Read("jh");
                            item.remark      = r.Read("remark");
                            lst3.Add(item);
                        }
                    }
                    if (lst1.Count > 0 || lst2.Count > 0)
                    {
                        bll.WriteFHD(lst1, lst2, lst3);
                    }
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    res = w.ToString();
                }
                else if (t == "upload_cgrk")
                {
                    if (CommonHelper.ExistsKeys(kv, "branch_no", "inout_master", "inout_detail", "pay_data") == false)
                    {
                        throw new Exception("参数错误");
                    }
                    var branch_no = rm.Read("branch_no");
                    var json      = rm.Read("inout_master");
                    ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json);
                    var lst1 = new List <Model.ic_t_inout_store_master>();
                    if (read.Read("datas") != null)
                    {
                        foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                        {
                            var ord = new Model.ic_t_inout_store_master();
                            ord.sheet_no     = r.Read("sheet_no");
                            ord.trans_no     = r.Read("trans_no");//A采购入库; D销售退货入库
                            ord.db_no        = "+";
                            ord.branch_no    = r.Read("branch_no");
                            ord.d_branch_no  = "";
                            ord.voucher_no   = "";
                            ord.supcust_no   = r.Read("supcust_no");
                            ord.total_amount = Conv.ToDecimal(r.Read("total_amount"));
                            ord.inout_amount = Conv.ToDecimal(r.Read("total_amount"));
                            ord.coin_no      = "RMB";
                            ord.pay_way      = r.Read("pay_way");
                            ord.tax_amount   = 0m;
                            ord.discount     = 0m;
                            ord.pay_date     = DateTime.MinValue;
                            ord.approve_flag = "0";
                            ord.oper_date    = Conv.ToDateTime(r.Read("oper_date"));
                            ord.oper_id      = r.Read("oper_id");
                            ord.display_flag = "1";
                            ord.other1       = "";
                            ord.other2       = "";
                            ord.other3       = "";
                            ord.cm_branch    = ""; //不确定
                            ord.deal_man     = "";
                            ord.old_no       = "";
                            ord.approve_man  = "";
                            ord.approve_date = DateTime.MinValue;
                            ord.num1         = 0m;
                            ord.num2         = 0m;
                            ord.num3         = 0m;
                            ord.max_change   = 0m; //不确定
                            ord.sale_no      = "A";
                            ord.lock_man     = "";
                            ord.lock_date    = DateTime.MinValue;

                            lst1.Add(ord);
                        }
                    }

                    json = rm.Read("inout_detail");
                    read = new ReadWriteContext.ReadContextByJson(json);
                    var lst2 = new List <Model.ic_t_inout_store_detail>();
                    if (read.Read("datas") != null)
                    {
                        foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                        {
                            var item = new Model.ic_t_inout_store_detail();
                            item.sheet_no    = r.Read("sheet_no");
                            item.item_no     = r.Read("item_no");
                            item.item_name   = r.Read("item_name");
                            item.unit_no     = r.Read("unit_no");
                            item.unit_factor = 1m;
                            item.in_qty      = Conv.ToDecimal(r.Read("in_qty"));
                            item.orgi_price  = Conv.ToDecimal(r.Read("orgi_price"));
                            item.valid_price = Conv.ToDecimal(r.Read("valid_price"));
                            item.cost_price  = Conv.ToDecimal(r.Read("cost_price"));
                            item.sub_amount  = 0m;
                            item.tax         = 0m;
                            item.is_tax      = "0";
                            item.valid_date  = Conv.ToDateTime(r.Read("valid_date"));
                            item.other1      = "";
                            item.other2      = "";
                            item.other3      = "";
                            item.num1        = 0m;
                            item.num2        = 0m;
                            item.num3        = 0m;
                            item.num4        = 0m;
                            item.num5        = 0m;
                            item.num6        = 0m;
                            item.barcode     = r.Read("barcode");
                            item.sheet_sort  = Conv.ToInt(r.Read("sheet_sort"));
                            item.ret_qnty    = 0m;
                            item.discount    = 1m;
                            item.voucher_no  = "";
                            item.cost_notax  = 0m; //不确定
                            item.packqty     = 0;
                            item.sgqty       = 0m;
                            item.branch_no_d = "";
                            item.ly_sup_no   = "";
                            item.ly_rate     = 0m;
                            lst2.Add(item);
                        }
                    }
                    json = rm.Read("pay_data");
                    read = new ReadWriteContext.ReadContextByJson(json);
                    var lst3 = new List <Model.ot_pay_flow>();
                    if (read.Read("datas") != null)
                    {
                        foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                        {
                            var item = new Model.ot_pay_flow();
                            item.sheet_no    = r.Read("sheet_no");
                            item.flow_id     = Conv.ToInt(r.Read("flow_id"));
                            item.cus_no      = r.Read("cus_no");
                            item.oper_id     = r.Read("oper_id");
                            item.oper_date   = Conv.ToDateTime(r.Read("oper_date"));
                            item.pay_way     = r.Read("pay_way");
                            item.sale_amount = Conv.ToDecimal(r.Read("sale_amount"));
                            item.pay_amount  = Conv.ToDecimal(r.Read("pay_amount"));
                            item.old_amount  = Conv.ToDecimal(r.Read("old_amount"));
                            item.ml          = Conv.ToDecimal(r.Read("ml"));
                            item.jh          = r.Read("jh");
                            item.remark      = r.Read("remark");
                            lst3.Add(item);
                        }
                    }
                    if (lst1.Count > 0 || lst2.Count > 0)
                    {
                        bll.WriteCGRK(lst1, lst2, lst3);
                    }
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    res = w.ToString();
                }
                else
                {
                    throw new Exception("未找到方法:" + t);
                }
            }
            catch (Exception ex)
            {
                LogHelper.writeLog("settle()", ex.ToString(), t, pars);
                ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                w.Append("errId", "-1");
                w.Append("errMsg", ex.Message);
                res = w.ToString();
            }
        }
Exemple #3
0
        void IServiceBase.Request(string t, string pars, out string res)
        {
            try
            {
                ReadWriteContext.IReadContext r = new ReadWriteContext.ReadContextByJson(pars);
                var            kv  = r.ToDictionary();
                IBLL.IInOutBLL bll = new BLL.InOutBLL();
                if (t == "get_salesheet_list")
                {
                    string date1    = r.Read("date1");
                    string date2    = r.Read("date2");
                    string cust_id  = r.Read("cust_id");
                    string sale_man = r.Read("sale_man");

                    var tb = bll.GetSaleSheetList(date1, date2, cust_id, sale_man);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("data", tb);

                    res = w.ToString();
                }
                else if (t == "get_simple_salesheet_list")
                {
                    string date1   = r.Read("date1");
                    string date2   = r.Read("date2");
                    string cust_id = r.Read("cust_id");

                    var tb = bll.GetSimpleSaleSheetList(date1, date2, cust_id);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("data", tb);

                    res = w.ToString();
                }
                else if (t == "get_salesheet")
                {
                    string sheet_no = r.Read("sheet_no");
                    System.Data.DataTable tb1;
                    System.Data.DataTable tb2;
                    bll.GetSaleSheet(sheet_no, out tb1, out tb2);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("tb1", tb1);
                    w.Append("tb2", tb2);
                    res = w.ToString();
                }
                else if (t == "add_salesheet")
                {
                    var ord = new Model.sm_t_salesheet();

                    ord.sheet_no = r.Read("sheet_no");

                    ord.voucher_no   = r.Read("voucher_no");
                    ord.branch_no    = r.Read("branch_no");
                    ord.cust_no      = r.Read("cust_no");
                    ord.pay_way      = r.Read("pay_way");
                    ord.discount     = Helper.Conv.ToDecimal(r.Read("discount"));
                    ord.coin_no      = r.Read("coin_no");
                    ord.real_amount  = Helper.Conv.ToDecimal(r.Read("real_amount"));
                    ord.total_amount = Helper.Conv.ToDecimal(r.Read("total_amount"));
                    ord.paid_amount  = Helper.Conv.ToDecimal(r.Read("paid_amount"));
                    ord.approve_flag = "0";
                    ord.source_flag  = "";
                    ord.oper_id      = r.Read("oper_id");
                    ord.sale_man     = r.Read("sale_man");
                    ord.oper_date    = Helper.Conv.ToDateTime(r.Read("oper_date"));
                    ord.pay_date     = Helper.Conv.ToDateTime(r.Read("pay_date"));
                    ord.other1       = r.Read("other1");
                    ord.other2       = r.Read("other2");
                    ord.other3       = r.Read("other3");
                    ord.cm_branch    = r.Read("cm_branch");
                    ord.approve_man  = "";
                    ord.approve_date = DateTime.MinValue;
                    ord.num1         = Helper.Conv.ToDecimal(r.Read("num1"));
                    ord.num2         = Helper.Conv.ToDecimal(r.Read("num2"));
                    ord.num3         = Helper.Conv.ToDecimal(r.Read("num3"));
                    ord.payfee_memo  = r.Read("payfee_memo");
                    ord.old_no       = "";
                    ord.psheet_no    = r.Read("psheet_no");
                    ord.pay_nowmark  = r.Read("pay_nowmark");
                    ord.if_back      = r.Read("if_back");
                    ord.cust_cls     = "";
                    ord.other4       = r.Read("other4");

                    List <Model.sm_t_salesheet_detail> lines = new List <Model.sm_t_salesheet_detail>();
                    foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines"))
                    {
                        var item = new Model.sm_t_salesheet_detail();
                        item.sheet_no    = r2.Read("sheet_no");
                        item.item_no     = r2.Read("item_no");
                        item.item_name   = r2.Read("item_name");
                        item.unit_no     = r2.Read("unit_no");
                        item.unit_factor = Helper.Conv.ToDecimal(r2.Read("unit_factor"));
                        item.sale_qnty   = Helper.Conv.ToDecimal(r2.Read("sale_qnty"));
                        item.sale_price  = Helper.Conv.ToDecimal(r2.Read("sale_price"));
                        item.real_price  = Helper.Conv.ToDecimal(r2.Read("real_price"));
                        item.cost_price  = Helper.Conv.ToDecimal(r2.Read("cost_price"));
                        item.sale_money  = Helper.Conv.ToDecimal(r2.Read("sale_money"));
                        item.sale_tax    = Helper.Conv.ToDecimal(r2.Read("sale_tax"));
                        item.is_tax      = r2.Read("is_tax");
                        item.other1      = r2.Read("other1");
                        item.other2      = r2.Read("other2");
                        item.other3      = r2.Read("other3");
                        item.other4      = r2.Read("other4");
                        item.num1        = Helper.Conv.ToDecimal(r2.Read("num1"));
                        item.num2        = Helper.Conv.ToDecimal(r2.Read("num2"));
                        item.num3        = Helper.Conv.ToDecimal(r2.Read("num3"));
                        item.num4        = Helper.Conv.ToDecimal(r2.Read("num4"));
                        item.num5        = Helper.Conv.ToDecimal(r2.Read("num5"));
                        item.num6        = Helper.Conv.ToDecimal(r2.Read("num6"));
                        item.barcode     = r2.Read("barcode");
                        item.sheet_sort  = Helper.Conv.ToInt(r2.Read("sheet_sort"));
                        item.ret_qnty    = Helper.Conv.ToDecimal(r2.Read("ret_qnty"));
                        item.discount    = Helper.Conv.ToDecimal(r2.Read("discount"));
                        item.voucher_no  = r2.Read("voucher_no");
                        item.cost_notax  = Helper.Conv.ToDecimal(r2.Read("cost_notax"));
                        item.packqty     = Helper.Conv.ToInt(r2.Read("packqty"));
                        item.sgqty       = Helper.Conv.ToDecimal(r2.Read("sgqty"));
                        item.branch_no_d = "";
                        item.ly_sup_no   = "";
                        item.ly_rate     = 0M;
                        item.num7        = Helper.Conv.ToDecimal(r2.Read("num7"));
                        item.other5      = r2.Read("other5");
                        item.num8        = Helper.Conv.ToDecimal(r2.Read("num8"));
                        item.produce_day = DateTime.MinValue;
                        lines.Add(item);
                    }
                    string sheet_no = "";
                    bll.AddSaleSheet(ord, lines, out sheet_no);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("sheet_no", sheet_no);
                    res = w.ToString();
                }
                else if (t == "change_salesheet")
                {
                    var ord = new Model.sm_t_salesheet();
                    ord.sheet_no     = r.Read("sheet_no");
                    ord.voucher_no   = r.Read("voucher_no");
                    ord.branch_no    = r.Read("branch_no");
                    ord.cust_no      = r.Read("cust_no");
                    ord.pay_way      = r.Read("pay_way");
                    ord.discount     = Helper.Conv.ToDecimal(r.Read("discount"));
                    ord.coin_no      = r.Read("coin_no");
                    ord.real_amount  = Helper.Conv.ToDecimal(r.Read("real_amount"));
                    ord.total_amount = Helper.Conv.ToDecimal(r.Read("total_amount"));
                    ord.paid_amount  = Helper.Conv.ToDecimal(r.Read("paid_amount"));
                    ord.approve_flag = "0";
                    ord.source_flag  = "";
                    ord.oper_id      = r.Read("oper_id");
                    ord.sale_man     = r.Read("sale_man");
                    ord.oper_date    = Helper.Conv.ToDateTime(r.Read("oper_date"));
                    ord.pay_date     = DateTime.MinValue;
                    ord.other1       = r.Read("other1");
                    ord.other2       = r.Read("other2");
                    ord.other3       = r.Read("other3");
                    ord.cm_branch    = r.Read("cm_branch");
                    ord.approve_man  = "";
                    ord.approve_date = DateTime.MinValue;
                    ord.num1         = Helper.Conv.ToDecimal(r.Read("num1"));
                    ord.num2         = Helper.Conv.ToDecimal(r.Read("num2"));
                    ord.num3         = Helper.Conv.ToDecimal(r.Read("num3"));
                    ord.payfee_memo  = r.Read("payfee_memo");
                    ord.old_no       = "";
                    ord.psheet_no    = r.Read("psheet_no");
                    ord.pay_nowmark  = r.Read("pay_nowmark");
                    ord.if_back      = r.Read("if_back");
                    ord.cust_cls     = "";
                    ord.other4       = r.Read("other4");
                    ord.update_time  = Helper.Conv.ToDateTime(r.Read("update_time"));

                    List <Model.sm_t_salesheet_detail> lines = new List <Model.sm_t_salesheet_detail>();
                    foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines"))
                    {
                        var item = new Model.sm_t_salesheet_detail();
                        item.sheet_no    = r2.Read("sheet_no");
                        item.item_no     = r2.Read("item_no");
                        item.item_name   = r2.Read("item_name");
                        item.unit_no     = r2.Read("unit_no");
                        item.unit_factor = Helper.Conv.ToDecimal(r2.Read("unit_factor"));
                        item.sale_qnty   = Helper.Conv.ToDecimal(r2.Read("sale_qnty"));
                        item.sale_price  = Helper.Conv.ToDecimal(r2.Read("sale_price"));
                        item.real_price  = Helper.Conv.ToDecimal(r2.Read("real_price"));
                        item.cost_price  = Helper.Conv.ToDecimal(r2.Read("cost_price"));
                        item.sale_money  = Helper.Conv.ToDecimal(r2.Read("sale_money"));
                        item.sale_tax    = Helper.Conv.ToDecimal(r2.Read("sale_tax"));
                        item.is_tax      = r2.Read("is_tax");
                        item.other1      = r2.Read("other1");
                        item.other2      = r2.Read("other2");
                        item.other3      = r2.Read("other3");
                        item.other4      = r2.Read("other4");
                        item.num1        = Helper.Conv.ToDecimal(r2.Read("num1"));
                        item.num2        = Helper.Conv.ToDecimal(r2.Read("num2"));
                        item.num3        = Helper.Conv.ToDecimal(r2.Read("num3"));
                        item.num4        = Helper.Conv.ToDecimal(r2.Read("num4"));
                        item.num5        = Helper.Conv.ToDecimal(r2.Read("num5"));
                        item.num6        = Helper.Conv.ToDecimal(r2.Read("num6"));
                        item.barcode     = r2.Read("barcode");
                        item.sheet_sort  = Helper.Conv.ToInt(r2.Read("sheet_sort"));
                        item.ret_qnty    = Helper.Conv.ToDecimal(r2.Read("ret_qnty"));
                        item.discount    = Helper.Conv.ToDecimal(r2.Read("discount"));
                        item.voucher_no  = r2.Read("voucher_no");
                        item.cost_notax  = Helper.Conv.ToDecimal(r2.Read("cost_notax"));
                        item.packqty     = Helper.Conv.ToInt(r2.Read("packqty"));
                        item.sgqty       = Helper.Conv.ToDecimal(r2.Read("sgqty"));
                        item.branch_no_d = "";
                        item.ly_sup_no   = "";
                        item.ly_rate     = 0M;
                        item.num7        = Helper.Conv.ToDecimal(r2.Read("num7"));
                        item.other5      = r2.Read("other5");
                        item.num8        = Helper.Conv.ToDecimal(r2.Read("num8"));
                        item.produce_day = DateTime.MinValue;
                        lines.Add(item);
                    }
                    bll.ChangeSaleSheet(ord, lines);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else if (t == "delete_salesheet")
                {
                    string sheet_no    = r.Read("sheet_no");
                    var    update_time = Helper.Conv.ToDateTime(r.Read("update_time"));
                    bll.DeleteSaleSheet(sheet_no, update_time);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else if (t == "check_salesheet")
                {
                    string sheet_no    = r.Read("sheet_no");
                    string approve_man = r.Read("approve_man");
                    var    update_time = Helper.Conv.ToDateTime(r.Read("update_time"));
                    bll.CheckSaleSheet(sheet_no, approve_man, update_time);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else if (t == "get_inout_list")
                {
                    string date1      = r.Read("date1");
                    string date2      = r.Read("date2");
                    string supcust_no = r.Read("supcust_no");
                    string trans_no   = r.Read("trans_no");

                    var tb = bll.GetInOutList(date1, date2, supcust_no, trans_no);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("data", tb);

                    res = w.ToString();
                }
                else if (t == "get_simple_inout_list")
                {
                    string date1      = r.Read("date1");
                    string date2      = r.Read("date2");
                    string supcust_no = r.Read("supcust_no");
                    string trans_no   = r.Read("trans_no");

                    var tb = bll.GetSimpleInOutList(date1, date2, supcust_no, trans_no);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("data", tb);

                    res = w.ToString();
                }
                else if (t == "get_other_inout_list")
                {
                    string date1    = r.Read("date1");
                    string date2    = r.Read("date2");
                    string trans_no = r.Read("trans_no");

                    var tb = bll.GetOtherInOutList(date1, date2, trans_no);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("data", tb);

                    res = w.ToString();
                }
                else if (t == "get_inout")
                {
                    string sheet_no = r.Read("sheet_no");
                    string trans_no = r.Read("trans_no");
                    System.Data.DataTable tb1;
                    System.Data.DataTable tb2;
                    bll.GetInOut(sheet_no, trans_no, out tb1, out tb2);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("tb1", tb1);
                    w.Append("tb2", tb2);
                    res = w.ToString();
                }
                else if (t == "get_other_inout")
                {
                    string sheet_no = r.Read("sheet_no");
                    System.Data.DataTable tb1;
                    System.Data.DataTable tb2;
                    bll.GetInOut(sheet_no, out tb1, out tb2);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("tb1", tb1);
                    w.Append("tb2", tb2);
                    res = w.ToString();
                }
                else if (t == "add_inout")
                {
                    var ord = new Model.ic_t_inout_store_master();
                    ord.sheet_no     = r.Read("sheet_no");
                    ord.trans_no     = r.Read("trans_no");
                    ord.branch_no    = r.Read("branch_no");
                    ord.d_branch_no  = r.Read("d_branch_no");
                    ord.voucher_no   = r.Read("voucher_no");
                    ord.supcust_no   = r.Read("supcust_no");
                    ord.total_amount = Helper.Conv.ToDecimal(r.Read("total_amount"));
                    ord.inout_amount = Helper.Conv.ToDecimal(r.Read("inout_amount"));
                    ord.coin_no      = r.Read("coin_no");
                    ord.pay_way      = r.Read("pay_way");
                    ord.tax_amount   = Helper.Conv.ToDecimal(r.Read("tax_amount"));
                    ord.discount     = Helper.Conv.ToDecimal(r.Read("discount"));
                    ord.pay_date     = Helper.Conv.ToDateTime(r.Read("pay_date"));
                    ord.approve_flag = "0";
                    ord.oper_date    = Helper.Conv.ToDateTime(r.Read("oper_date"));
                    ord.oper_id      = r.Read("oper_id");
                    ord.display_flag = "1";
                    ord.other1       = r.Read("other1");
                    ord.other2       = r.Read("other2");
                    ord.other3       = r.Read("other3");
                    ord.cm_branch    = r.Read("cm_branch"); //不确定
                    ord.deal_man     = r.Read("deal_man");
                    ord.old_no       = "";
                    ord.approve_man  = r.Read("approve_man");
                    ord.approve_date = DateTime.MinValue;
                    ord.num1         = Helper.Conv.ToDecimal(r.Read("num1"));
                    ord.num2         = Helper.Conv.ToDecimal(r.Read("num2"));
                    ord.num3         = Helper.Conv.ToDecimal(r.Read("num3"));
                    ord.max_change   = 0m; //不确定
                    ord.sale_no      = r.Read("sale_no");
                    ord.lock_man     = "";
                    ord.lock_date    = DateTime.MinValue;

                    List <Model.ic_t_inout_store_detail> lines = new List <Model.ic_t_inout_store_detail>();
                    foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines"))
                    {
                        var item = new Model.ic_t_inout_store_detail();
                        item.sheet_no    = r2.Read("sheet_no");
                        item.item_no     = r2.Read("item_no");
                        item.item_name   = r2.Read("item_name");
                        item.unit_no     = r2.Read("unit_no");
                        item.unit_factor = Helper.Conv.ToDecimal(r2.Read("unit_factor"));
                        item.in_qty      = Helper.Conv.ToDecimal(r2.Read("in_qty"));
                        item.orgi_price  = Helper.Conv.ToDecimal(r2.Read("orgi_price"));
                        item.valid_price = Helper.Conv.ToDecimal(r2.Read("valid_price"));
                        item.cost_price  = Helper.Conv.ToDecimal(r2.Read("cost_price"));
                        item.sub_amount  = Helper.Conv.ToDecimal(r2.Read("sub_amount"));
                        item.tax         = Helper.Conv.ToDecimal(r2.Read("tax"));
                        item.is_tax      = r2.Read("is_tax");
                        item.valid_date  = Helper.Conv.ToDateTime(r2.Read("valid_date"));
                        item.other1      = r2.Read("other1");
                        item.other2      = r2.Read("other2");
                        item.other3      = r2.Read("other3");
                        item.num1        = Helper.Conv.ToDecimal(r2.Read("num1"));
                        item.num2        = Helper.Conv.ToDecimal(r2.Read("num2"));
                        item.num3        = Helper.Conv.ToDecimal(r2.Read("num3"));
                        item.num4        = Helper.Conv.ToDecimal(r2.Read("num4"));
                        item.num5        = Helper.Conv.ToDecimal(r2.Read("num5"));
                        item.num6        = Helper.Conv.ToDecimal(r2.Read("num6"));
                        item.barcode     = r2.Read("barcode");
                        item.sheet_sort  = Helper.Conv.ToInt(r2.Read("sheet_sort"));
                        item.ret_qnty    = Helper.Conv.ToDecimal(r2.Read("ret_qnty"));
                        item.discount    = Helper.Conv.ToDecimal(r2.Read("discount"));
                        item.voucher_no  = r2.Read("voucher_no");
                        item.cost_notax  = 0m; //不确定
                        item.packqty     = Helper.Conv.ToInt(r2.Read("packqty"));
                        item.sgqty       = Helper.Conv.ToDecimal(r2.Read("sgqty"));
                        item.branch_no_d = "";
                        item.ly_sup_no   = "";
                        item.ly_rate     = 0m;
                        lines.Add(item);
                    }
                    string sheet_no = "";
                    bll.AddInOut(ord, lines, out sheet_no);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("sheet_no", sheet_no);
                    res = w.ToString();
                }
                else if (t == "change_inout")
                {
                    var ord = new Model.ic_t_inout_store_master();
                    ord.sheet_no     = r.Read("sheet_no");
                    ord.trans_no     = r.Read("trans_no");
                    ord.branch_no    = r.Read("branch_no");
                    ord.d_branch_no  = "";
                    ord.db_no        = r.Read("db_no");
                    ord.voucher_no   = r.Read("voucher_no");
                    ord.supcust_no   = r.Read("supcust_no");
                    ord.total_amount = Helper.Conv.ToDecimal(r.Read("total_amount"));
                    ord.inout_amount = Helper.Conv.ToDecimal(r.Read("inout_amount"));
                    ord.coin_no      = "RMB";
                    ord.pay_way      = r.Read("pay_way");
                    ord.tax_amount   = Helper.Conv.ToDecimal(r.Read("tax_amount"));
                    ord.discount     = Helper.Conv.ToDecimal(r.Read("discount"));
                    ord.pay_date     = Helper.Conv.ToDateTime(r.Read("pay_date"));
                    ord.approve_flag = "0";
                    ord.oper_date    = Helper.Conv.ToDateTime(r.Read("oper_date"));
                    ord.oper_id      = r.Read("oper_id");
                    ord.display_flag = "1";
                    ord.other1       = r.Read("other1");
                    ord.other2       = r.Read("other2");
                    ord.other3       = r.Read("other3");
                    ord.cm_branch    = r.Read("cm_branch"); //不确定
                    ord.deal_man     = r.Read("deal_man");
                    ord.old_no       = "";
                    ord.approve_man  = r.Read("approve_man");
                    ord.approve_date = DateTime.MinValue;
                    ord.num1         = Helper.Conv.ToDecimal(r.Read("num1"));
                    ord.num2         = Helper.Conv.ToDecimal(r.Read("num2"));
                    ord.num3         = Helper.Conv.ToDecimal(r.Read("num3"));
                    ord.max_change   = 0m; //不确定
                    ord.sale_no      = r.Read("sale_no");
                    ord.lock_man     = "";
                    ord.lock_date    = DateTime.MinValue;
                    ord.update_time  = Helper.Conv.ToDateTime(r.Read("update_time"));

                    List <Model.ic_t_inout_store_detail> lines = new List <Model.ic_t_inout_store_detail>();
                    foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines"))
                    {
                        var item = new Model.ic_t_inout_store_detail();
                        item.sheet_no    = r2.Read("sheet_no");
                        item.item_no     = r2.Read("item_no");
                        item.item_name   = r2.Read("item_name");
                        item.unit_no     = r2.Read("unit_no");
                        item.unit_factor = Helper.Conv.ToDecimal(r2.Read("unit_factor"));
                        item.in_qty      = Helper.Conv.ToDecimal(r2.Read("in_qty"));
                        item.orgi_price  = Helper.Conv.ToDecimal(r2.Read("orgi_price"));
                        item.valid_price = Helper.Conv.ToDecimal(r2.Read("valid_price"));
                        item.cost_price  = Helper.Conv.ToDecimal(r2.Read("cost_price"));
                        item.sub_amount  = Helper.Conv.ToDecimal(r2.Read("sub_amount"));
                        item.tax         = Helper.Conv.ToDecimal(r2.Read("tax"));
                        item.is_tax      = r2.Read("is_tax");
                        item.valid_date  = Helper.Conv.ToDateTime(r2.Read("valid_date"));
                        item.other1      = r2.Read("other1");
                        item.other2      = r2.Read("other2");
                        item.other3      = r2.Read("other3");
                        item.num1        = Helper.Conv.ToDecimal(r2.Read("num1"));
                        item.num2        = Helper.Conv.ToDecimal(r2.Read("num2"));
                        item.num3        = Helper.Conv.ToDecimal(r2.Read("num3"));
                        item.num4        = Helper.Conv.ToDecimal(r2.Read("num4"));
                        item.num5        = Helper.Conv.ToDecimal(r2.Read("num5"));
                        item.num6        = Helper.Conv.ToDecimal(r2.Read("num6"));
                        item.barcode     = r2.Read("barcode");
                        item.sheet_sort  = Helper.Conv.ToInt(r2.Read("sheet_sort"));
                        item.ret_qnty    = Helper.Conv.ToDecimal(r2.Read("ret_qnty"));
                        item.discount    = Helper.Conv.ToDecimal(r2.Read("discount"));
                        item.voucher_no  = r2.Read("voucher_no");
                        item.cost_notax  = 0m; //不确定
                        item.packqty     = Helper.Conv.ToInt(r2.Read("packqty"));
                        item.sgqty       = Helper.Conv.ToDecimal(r2.Read("sgqty"));
                        item.branch_no_d = "";
                        item.ly_sup_no   = "";
                        item.ly_rate     = 0m;
                        lines.Add(item);
                    }
                    bll.ChangeInOut(ord, lines);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else if (t == "delete_inout")
                {
                    string sheet_no    = r.Read("sheet_no");
                    var    update_time = Helper.Conv.ToDateTime(r.Read("update_time"));
                    bll.DeleteInOut(sheet_no, update_time);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else if (t == "check_inout")
                {
                    string sheet_no    = r.Read("sheet_no");
                    string approve_man = r.Read("approve_man");
                    var    update_time = Helper.Conv.ToDateTime(r.Read("update_time"));
                    bll.CheckInOut(sheet_no, approve_man, update_time);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else
                {
                    throw new Exception("未找到方法[" + t + "]");
                }
            }
            catch (Exception ex)
            {
                ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                w.Append("errId", "-1");
                w.Append("errMsg", ex.Message);
                LogHelper.writeLog("inout()", ex.ToString(), t, pars);
                res = w.ToString();
            }
        }