コード例 #1
0
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txt_cust.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("客户编码必填!");
                    return;
                }
                if (txtbranch.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("机构必填!");
                    return;
                }
                if (txtoper_date.Text.Trim() == "")
                {
                    MsgForm.ShowFrom("单据日期必填!");
                    return;
                }

                sm_t_salesheet ord = new sm_t_salesheet();
                List <sm_t_salesheet_detail> lines = new List <sm_t_salesheet_detail>();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.branch_no    = txtbranch.Text.Trim().Split('/')[0];
                ord.voucher_no   = txt_voucher_no.Text.Trim();
                ord.cust_no      = txt_cust.Text.Trim().Split('/')[0];
                ord.pay_way      = "";
                ord.discount     = Helper.Conv.ToDecimal(txt_discount.Text.Trim());
                ord.coin_no      = lbl_coin_no.Text.Trim();
                ord.paid_amount  = Helper.Conv.ToDecimal(txt_paid_amount.Text);
                ord.oper_date    = Helper.Conv.ToDateTime(txtoper_date.Text.Trim());
                ord.oper_id      = txtoper_man.Text.Split('/')[0];
                ord.sale_man     = txt_sale_man.Text.Split('/')[0];
                ord.approve_flag = "0";
                ord.other1       = "";
                ord.other2       = (txt_other2.Text.Trim() == "是" ? "1" : "0");
                ord.other3       = "";
                ord.other4       = "";
                ord.old_no       = txt_old_no.Text.Trim();
                ord.cm_branch    = "00";
                ord.psheet_no    = "";
                ord.pay_nowmark  = "";
                ord.payfee_memo  = txtmemo.Text.Trim();
                ord.if_back      = "0";
                ord.approve_man  = txtapprove_man.Text.Split('/')[0];
                ord.approve_date = System.DateTime.MinValue;
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                ord.pay_date     = Helper.Conv.ToDateTime(txt_pay_date.Text.Trim());
                ord.create_time  = DateTime.Now;
                ord.update_time  = update_time;

                int     flag      = 0;
                int     index     = 0;
                decimal total_amt = 0;
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    ++index;
                    if (row["item_no"].ToString() != "")
                    {
                        sm_t_salesheet_detail line = new sm_t_salesheet_detail();
                        lines.Add(line);
                        line.sheet_no    = ord.sheet_no;
                        line.item_no     = row["item_no"].ToString();
                        line.item_name   = row["item_name"].ToString();
                        line.unit_no     = row["unit_no"].ToString();
                        line.barcode     = row["barcode"].ToString();
                        line.unit_factor = 1;
                        line.sale_qnty   = Helper.Conv.ToDecimal(row["sale_qnty"].ToString());
                        line.sale_price  = Helper.Conv.ToDecimal(row["real_price"].ToString());
                        line.real_price  = Helper.Conv.ToDecimal(row["real_price"].ToString());
                        line.cost_price  = 0;
                        line.sale_money  = Helper.Conv.ToDecimal(row["sale_money"].ToString());
                        line.discount    = 1;
                        line.sale_tax    = 0;
                        line.is_tax      = "0";
                        line.other1      = "";
                        line.other2      = "";
                        line.other3      = (row["other3"].ToString() == "是" ? "1" : "0");
                        line.other4      = "";
                        line.other5      = row["other5"].ToString();
                        line.voucher_no  = "";
                        line.sheet_sort  = index;
                        line.ret_qnty    = 0;
                        line.num1        = 0;
                        line.num2        = 0;
                        line.num3        = 0;
                        line.num4        = 0;
                        line.num5        = 0;
                        line.num6        = 0;
                        line.num7        = 0;
                        line.num8        = 0;
                        line.cost_notax  = 0;
                        line.packqty     = 0;
                        line.sgqty       = 0;
                        flag             = 1;
                        total_amt       += line.sale_qnty * line.real_price;
                    }
                }
                if (flag == 0)
                {
                    MsgForm.ShowFrom("请输入表单明细");
                    return;
                }
                ord.real_amount  = total_amt;
                ord.total_amount = total_amt;
                if (runType == 1)
                {
                    IBLL.IInOutBLL bll      = new BLL.InOutBLL();
                    var            sheet_no = "";
                    bll.AddSaleSheet(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.IInOutBLL bll = new BLL.InOutBLL();
                    bll.ChangeSaleSheet(ord, lines);
                    IOrder ins = this;
                    ins.ShowOrder(ord.sheet_no);
                }

                Dictionary <string, object> dic = this.Tag as Dictionary <string, object>;
                this.Tag = Helper.Conv.ControlsAdds(this, dic);

                IBLL.ISys sys       = new BLL.SysBLL();
                string    isApprove = sys.Read("approve_at_ones");
                if ("1".Equals(isApprove))
                {
                    if (YesNoForm.ShowFrom("保存成功!是否立即审核") == DialogResult.Yes)
                    {
                        tsbCheck_Click(new object(), new EventArgs());
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.LogHelper.writeLog("frmSaleSheet->Save()", ex.ToString(), txtsheet_no.Text);
                MsgForm.ShowFrom("批发销售单保存异常[" + ex.Message + "]");
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
コード例 #2
0
        private void SaveSheet()
        {
            if (curr_cust == null || string.IsNullOrEmpty(curr_cust.supcust_no))
            {
                MsgForm.ShowFrom("请选择客户!");
                return;
            }
            if (sale_detail.Rows.Count < 1)
            {
                MsgForm.ShowFrom("请输入明细!");
                return;
            }

            sm_t_salesheet ord = new sm_t_salesheet();
            List <sm_t_salesheet_detail> lines = new List <sm_t_salesheet_detail>();

            ord.sheet_no     = "";
            ord.branch_no    = sale_master.branch_no;
            ord.voucher_no   = "";
            ord.cust_no      = sale_master.cust_no;
            ord.pay_way      = "";
            ord.discount     = 1;
            ord.coin_no      = "RMB";
            ord.paid_amount  = 0;
            ord.oper_date    = sale_master.oper_date;
            ord.oper_id      = Program.oper.oper_id;
            ord.sale_man     = "00";
            ord.approve_flag = "0";
            ord.other1       = sale_master.other1;
            ord.other2       = "0";
            ord.other3       = "";
            ord.other4       = "";
            ord.old_no       = "";
            ord.cm_branch    = "00";
            ord.psheet_no    = "";
            ord.pay_nowmark  = "";
            ord.payfee_memo  = "";
            ord.if_back      = "0";
            ord.approve_man  = "";
            ord.approve_date = System.DateTime.MinValue;
            ord.num1         = 0;
            ord.num2         = 0;
            ord.num3         = 0;
            ord.pay_date     = sale_master.oper_date.AddMonths(1);

            int     index     = 0;
            decimal total_amt = 0;

            foreach (DataRow row in sale_detail.Rows)
            {
                ++index;
                if (row["item_no"].ToString() != "")
                {
                    sm_t_salesheet_detail line = new sm_t_salesheet_detail();
                    lines.Add(line);
                    line.sheet_no    = ord.sheet_no;
                    line.item_no     = row["item_no"].ToString();
                    line.item_name   = row["item_name"].ToString();
                    line.unit_no     = row["unit_no"].ToString();
                    line.barcode     = row["barcode"].ToString();
                    line.unit_factor = 1;
                    line.sale_qnty   = Helper.Conv.ToDecimal(row["sale_qnty"].ToString());
                    line.sale_price  = Helper.Conv.ToDecimal(row["real_price"].ToString());
                    line.real_price  = Helper.Conv.ToDecimal(row["real_price"].ToString());
                    line.cost_price  = 0;
                    line.sale_money  = Helper.Conv.ToDecimal(row["sale_money"].ToString());
                    line.discount    = 1;
                    line.sale_tax    = 0;
                    line.is_tax      = "0";
                    line.other1      = row["other1"].ToString();
                    line.other2      = "";
                    line.other3      = "0";
                    line.other4      = "";
                    line.voucher_no  = "";
                    line.sheet_sort  = index;
                    line.ret_qnty    = 0;
                    line.num1        = 0;
                    line.num2        = 0;
                    line.num3        = 0;
                    line.num4        = 0;
                    line.num5        = 0;
                    line.num6        = 0;
                    line.num7        = 0;
                    line.num8        = 0;
                    line.cost_notax  = 0;
                    line.packqty     = 0;
                    line.sgqty       = 0;

                    total_amt += line.sale_qnty * line.real_price;
                }
            }
            ord.real_amount  = total_amt;
            ord.total_amount = total_amt;

            IBLL.IInOutBLL bll = new BLL.InOutBLL();
            bll.AddSaleSheet(ord, lines, out string sheet_no);

            NewSheet();
        }
コード例 #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();
            }
        }