private void dataGrid1_CurrentCellChange(object sender, string column_name, DataRow row)
        {
            try
            {
                if (sheet_no != row["sheet_no"].ToString())
                {
                    Thread th = new Thread(() =>
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        Helper.GlobalData.windows.ShowLoad(this);
                        try
                        {
                            sheet_no           = row["sheet_no"].ToString();
                            trans_no           = row["trans_no"].ToString();
                            IBLL.IInOutBLL bll = new BLL.InOutBLL();
                            System.Data.DataTable tb1;
                            System.Data.DataTable tb2;
                            bll.GetInOut(sheet_no, trans_no, out tb1, out tb2);

                            update_time = Helper.Conv.ToDateTime(tb1.Rows[0]["update_time"]);
                            this.dataGrid2.Invoke((MethodInvoker) delegate
                            {
                                this.dataGrid2.DataSource = tb2;
                            });
                        }
                        catch (Exception ex)
                        {
                            LogHelper.writeLog("dataGrid1_CurrentCellChange", ex.ToString());
                            MsgForm.ShowFrom(ex);
                        }
                        Cursor.Current = Cursors.Default;
                        Helper.GlobalData.windows.CloseLoad(this);
                    });
                    th.Start();
                }
            }
            catch (Exception ex)
            {
                MsgForm.ShowFrom(ex);
                Helper.LogHelper.writeLog("frmCGOutSheetList->dataGrid1_CurrentCellChange()", ex.ToString());
            }
        }
Exemple #2
0
 private void dataGrid1_CurrentCellChange(object sender, string column_name, DataRow row)
 {
     try
     {
         if (sheet_no != row["sheet_no"].ToString())
         {
             sheet_no = row["sheet_no"].ToString();
             trans_no = row["trans_no"].ToString();
             IBLL.IInOutBLL        bll = new BLL.InOutBLL();
             System.Data.DataTable tb1;
             System.Data.DataTable tb2;
             bll.GetInOut(sheet_no, trans_no, out tb1, out tb2);
             this.dataGrid2.DataSource = tb2;
             update_time = Helper.Conv.ToDateTime(tb1.Rows[0]["update_time"]);
         }
     }
     catch (Exception ex)
     {
         MsgForm.ShowFrom(ex);
         Helper.LogHelper.writeLog("frmIOMaster->dataGrid1_CurrentCellChange()", ex.ToString());
     }
 }
        private void refreshData()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                DateTime date1 = Helper.Conv.ToDateTime(dateTextBox1.Text.Trim());
                DateTime date2 = Helper.Conv.ToDateTime(dateTextBox2.Text.Trim());
                string   sup   = txt_sup_id.Text.Trim().Split('/')[0];
                Thread   th    = new Thread(() =>
                {
                    Helper.GlobalData.windows.ShowLoad(this);
                    try
                    {
                        IBLL.IInOutBLL bll = new BLL.InOutBLL();

                        if (date1 == DateTime.MinValue)
                        {
                            throw new Exception("期间不正确");
                        }
                        if (date2 == DateTime.MinValue)
                        {
                            throw new Exception("期间不正确");
                        }
                        //退货出库
                        DataTable tb = bll.GetInOutList(date1, date2, sup, "F");

                        this.dataGrid1.Invoke((MethodInvoker) delegate
                        {
                            this.dataGrid1.DataSource = tb;
                            if (tb.Rows.Count > 0)
                            {
                                sheet_no = tb.Rows[0]["sheet_no"].ToString();
                                trans_no = tb.Rows[0]["trans_no"].ToString();

                                System.Data.DataTable tb1;
                                System.Data.DataTable tb2;
                                bll.GetInOut(sheet_no, trans_no, out tb1, out tb2);

                                update_time = Helper.Conv.ToDateTime(tb1.Rows[0]["update_time"]);

                                this.dataGrid2.DataSource = tb2;
                            }
                        });
                    }
                    catch (Exception ex)
                    {
                        Helper.LogHelper.writeLog("frmCGOutSheetList->refreshData()", ex.ToString());
                        MsgForm.ShowFrom(ex);
                    }
                    Helper.GlobalData.windows.CloseLoad(this);
                });
                th.Start();
            }
            catch (Exception ex)
            {
                MsgForm.ShowFrom(ex);
                Helper.LogHelper.writeLog("frmCGOutSheetList->refreshData()", ex.ToString());
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
Exemple #4
0
        void IOrder.ShowOrder(string sheet_no)
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                RunType = 2;

                IBLL.IInOutBLL bll = new BLL.InOutBLL();
                DataTable      tb1;
                DataTable      tb2;
                bll.GetInOut(sheet_no, "A", out tb1, out tb2);
                //

                //
                var r1 = tb1.Rows[0];
                update_time   = Helper.Conv.ToDateTime(r1["update_time"]);
                this.sheet_no = sheet_no;
                if (r1["branch_no"].ToString() == "")
                {
                    txtbranch.Text = "";
                }
                else
                {
                    txtbranch.Text = r1["branch_no"].ToString() + "/" + r1["branch_name"].ToString();
                }
                txtsheet_no.Text  = r1["sheet_no"].ToString();
                txtoper_date.Text = Helper.Conv.ToDateTime(r1["oper_date"].ToString()).ToString("yyyy-MM-dd");
                if (r1["deal_man"].ToString() == "")
                {
                    txt_deal_man.Text = "";
                }
                else
                {
                    txt_deal_man.Text = r1["deal_man"].ToString() + "/" + r1["deal_man_name"].ToString();
                }
                if (r1["approve_man"].ToString() == "")
                {
                    txtapprove_man.Text = "";
                }
                else
                {
                    txtapprove_man.Text = r1["approve_man"].ToString() + "/" + r1["approve_man_name"].ToString();
                }
                if (r1["oper_id"].ToString() == "")
                {
                    txtoper_man.Text = "";
                }
                else
                {
                    txtoper_man.Text = r1["oper_id"] + "/" + r1["oper_name"];
                }
                txtapprove_date.Text = Helper.Conv.ToDateTime(r1["approve_date"]).ToString("yyyy-MM-dd");
                txt_pay_date.Text    = Helper.Conv.ToDateTime(r1["pay_date"]).ToString("yyyy-MM-dd");
                txt_voucher_no.Text  = r1["voucher_no"].ToString();
                txt_sup.Text         = r1["supcust_no"].ToString() + "/" + r1["sup_name"].ToString();
                var sale_name = "";
                var sale_no   = r1["sale_no"].ToString();
                if (sale_no == "A")
                {
                    sale_name = "购销";
                }
                else if (sale_no == "B")
                {
                    sale_name = "代销";
                }
                else if (sale_no == "C")
                {
                    sale_name = "联营";
                }
                else if (sale_no == "E")
                {
                    sale_name = "联营进货";
                }
                else if (sale_no == "Z")
                {
                    sale_name = "租赁";
                }
                txt_sale_no.Text = sale_no + "/" + sale_name;

                txt_other1.Text = r1["other1"].ToString();
                txt_other3.Text = r1["other3"].ToString();
                txt_old_no.Text = r1["old_no"].ToString();
                //
                editGrid1.DataSource = tb2;

                Dictionary <string, object> dic = this.Tag as Dictionary <string, object>;
                this.Tag = Helper.Conv.ControlsAdds(this, dic);
            }
            catch (Exception ex)
            {
                MsgForm.ShowFrom("加载采购入库单异常[" + ex.Message + "]");
                Helper.LogHelper.writeLog("frmCGInSheet->ShowOrder()", ex.ToString(), sheet_no);
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
Exemple #5
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();
            }
        }
        void IOrder.ShowOrder(string sheet_no)
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                RunType = 2;

                IBLL.IInOutBLL bll = new BLL.InOutBLL();
                DataTable      tb1;
                DataTable      tb2;
                bll.GetInOut(sheet_no, "G", out tb1, out tb2);
                //

                //
                var r1 = tb1.Rows[0];
                update_time   = Helper.Conv.ToDateTime(r1["update_time"]);
                this.sheet_no = sheet_no;
                if (r1["branch_no"].ToString() == "")
                {
                    txtBranchIn.Text = "";
                }
                else
                {
                    txtBranchIn.Text = r1["branch_no"].ToString() + "/" + r1["branch_name"].ToString();
                }
                txtsheet_no.Text  = r1["sheet_no"].ToString();
                txtoper_date.Text = Helper.Conv.ToDateTime(r1["oper_date"].ToString()).ToString("yyyy-MM-dd");
                if (r1["approve_man"].ToString() == "")
                {
                    txtapprove_man.Text = "";
                }
                else
                {
                    txtapprove_man.Text = r1["approve_man"].ToString() + "/" + r1["approve_man_name"].ToString();
                }
                if (r1["oper_id"].ToString() == "")
                {
                    txtoper_man.Text = "";
                }
                else
                {
                    txtoper_man.Text = r1["oper_id"] + "/" + r1["oper_name"];
                }
                txtapprove_date.Text = Helper.Conv.ToDateTime(r1["approve_date"]).ToString("yyyy-MM-dd");
                txt_BranchOut.Text   = r1["branch_no"].ToString() + "/" + r1["branch_name"].ToString();
                txt_other1.Text      = r1["other1"].ToString();
                //
                editGrid1.DataSource = tb2;

                Dictionary <string, object> dic = this.Tag as Dictionary <string, object>;
                this.Tag = Helper.Conv.ControlsAdds(this, dic);
            }
            catch (Exception ex)
            {
                MsgForm.ShowFrom("加载采购入库单异常[" + ex.Message + "]");
                Helper.LogHelper.writeLog("frmIOMaster->ShowOrder()", ex.ToString(), sheet_no);
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }