Ejemplo n.º 1
0
        void IServiceBase.Request(string t, string pars, out string res)
        {
            try
            {
                ReadWriteContext.IReadContext r = new ReadWriteContext.ReadContextByJson(pars);
                var           kv  = r.ToDictionary();
                IBLL.IFYOrder bll = new BLL.FYOrder();
                if (t == "get_list")
                {
                    DateTime date1   = Helper.Conv.ToDateTime(r.Read("date1"));
                    DateTime date2   = Helper.Conv.ToDateTime(r.Read("date2"));
                    string   visa_id = r.Read("visa_id");
                    var      tb      = bll.GetList(date1, date2, visa_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_order")
                {
                    string sheet_no = r.Read("sheet_no");
                    System.Data.DataTable tb1;
                    System.Data.DataTable tb2;
                    bll.GetOrder(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 == "max_code")
                {
                    string code = bll.MaxCode();
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");
                    w.Append("code", code);
                    res = w.ToString();
                }
                else if (t == "add")
                {
                    Model.bank_t_cash_master ord = new Model.bank_t_cash_master();
                    ord.sheet_no     = r.Read("sheet_no");
                    ord.branch_no    = r.Read("branch_no");
                    ord.voucher_no   = r.Read("voucher_no");
                    ord.visa_id      = r.Read("visa_id");
                    ord.visa_in      = "";
                    ord.pay_way      = r.Read("pay_way");
                    ord.coin_no      = "RMB";
                    ord.coin_rate    = 1;
                    ord.deal_man     = r.Read("deal_man");
                    ord.oper_id      = r.Read("oper_id");
                    ord.oper_date    = Helper.Conv.ToDateTime(r.Read("oper_date"));
                    ord.bill_total   = Helper.Conv.ToDecimal(r.Read("bill_total"));
                    ord.bill_flag    = r.Read("bill_flag");
                    ord.cm_branch    = "00";
                    ord.approve_flag = "0";
                    ord.approve_man  = "";
                    ord.approve_date = System.DateTime.MinValue;
                    ord.other1       = r.Read("other1");
                    ord.other2       = r.Read("other2");
                    ord.other3       = r.Read("other3");
                    ord.num1         = Helper.Conv.ToDecimal(r.Read("num1"));
                    ord.num2         = Helper.Conv.ToDecimal(r.Read("num2"));
                    ord.num3         = Helper.Conv.ToDecimal(r.Read("num3"));
                    List <Model.bank_t_cash_detail> lines = new List <Model.bank_t_cash_detail>();
                    foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines"))
                    {
                        Model.bank_t_cash_detail line = new Model.bank_t_cash_detail();
                        lines.Add(line);
                        line.sheet_no  = ord.sheet_no;
                        line.type_no   = r2.Read("type_no");
                        line.bill_cash = Helper.Conv.ToDecimal(r2.Read("bill_cash"));
                        line.memo      = r2.Read("memo");
                    }
                    string sheet_no = "";
                    bll.Add(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")
                {
                    Model.bank_t_cash_master ord = new Model.bank_t_cash_master();
                    ord.sheet_no     = r.Read("sheet_no");
                    ord.branch_no    = r.Read("branch_no");
                    ord.voucher_no   = r.Read("voucher_no");
                    ord.visa_id      = r.Read("visa_id");
                    ord.visa_in      = "";
                    ord.pay_way      = r.Read("pay_way");
                    ord.coin_no      = "RMB";
                    ord.coin_rate    = 1;
                    ord.deal_man     = r.Read("deal_man");
                    ord.oper_id      = r.Read("oper_id");
                    ord.oper_date    = Helper.Conv.ToDateTime(r.Read("oper_date"));
                    ord.bill_total   = Helper.Conv.ToDecimal(r.Read("bill_total"));
                    ord.bill_flag    = r.Read("bill_flag");
                    ord.cm_branch    = "00";
                    ord.approve_flag = "0";
                    ord.approve_man  = "";
                    ord.approve_date = System.DateTime.MinValue;
                    ord.other1       = r.Read("other1");
                    ord.other2       = r.Read("other2");
                    ord.other3       = r.Read("other3");
                    ord.num1         = Helper.Conv.ToDecimal(r.Read("num1"));
                    ord.num2         = Helper.Conv.ToDecimal(r.Read("num2"));
                    ord.num3         = Helper.Conv.ToDecimal(r.Read("num3"));
                    List <Model.bank_t_cash_detail> lines = new List <Model.bank_t_cash_detail>();
                    foreach (ReadWriteContext.IReadContext r2 in r.ReadList("lines"))
                    {
                        Model.bank_t_cash_detail line = new Model.bank_t_cash_detail();
                        lines.Add(line);
                        line.sheet_no  = ord.sheet_no;
                        line.type_no   = r2.Read("type_no");
                        line.bill_cash = Helper.Conv.ToDecimal(r2.Read("bill_cash"));
                        line.memo      = r2.Read("memo");
                    }
                    bll.Change(ord, lines);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else if (t == "delete")
                {
                    string sheet_no = r.Read("sheet_no");
                    bll.Delete(sheet_no);
                    ReadWriteContext.IWriteContext w = new ReadWriteContext.WriteContextByJson();
                    w.Append("errId", "0");
                    w.Append("errMsg", "");

                    res = w.ToString();
                }
                else if (t == "check")
                {
                    string sheet_no    = r.Read("sheet_no");
                    string approve_man = r.Read("approve_man");
                    bll.Check(sheet_no, approve_man);
                    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("", ex.ToString());
                res = w.ToString();
            }
        }
Ejemplo n.º 2
0
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txtpay_way.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("付款方式必填!");
                }
                if (txtbranch.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("机构必填!");
                }
                if (txtoper_date.Text.Trim() == "")
                {
                    throw new Exception("单据日期必填!");
                }
                if (this.txtvisa.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("账户必填!");
                }
                Model.bank_t_cash_master ord = new Model.bank_t_cash_master();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.branch_no    = txtbranch.Text.Trim().Split('/')[0];
                ord.voucher_no   = txtold_no.Text.Trim();
                ord.visa_id      = txtvisa.Text.Trim().Split('/')[0];
                ord.visa_in      = "";
                ord.pay_way      = txtpay_way.Text.Split('/')[0];
                ord.coin_no      = "RMB";
                ord.coin_rate    = 1;
                ord.deal_man     = txtpeople.Text.Trim().Split('/')[0];
                ord.oper_id      = txtoper_man.Text.Trim().Split('/')[0];
                ord.oper_date    = Helper.Conv.ToDateTime(txtoper_date.Text);
                ord.bill_flag    = "S";
                ord.cm_branch    = "00";
                ord.approve_flag = "0";
                ord.approve_man  = "";
                ord.approve_date = System.DateTime.MinValue;
                ord.other1       = txtmemo.Text.Trim();
                ord.other2       = "";
                ord.other3       = "";
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                int flag = 0;
                List <Model.bank_t_cash_detail> lines = new List <Model.bank_t_cash_detail>();
                int index = 0;
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    index++;
                    if (row["type_no"].ToString() != "")
                    {
                        if (Helper.Conv.ToDecimal(row["bill_cash"].ToString()) <= 0)
                        {
                            throw new Exception("第i行费用金额不正确!".Replace("i", index.ToString()));
                        }
                        Model.bank_t_cash_detail line = new Model.bank_t_cash_detail();
                        lines.Add(line);
                        line.sheet_no  = ord.sheet_no;
                        line.type_no   = row["type_no"].ToString();
                        line.bill_cash = Helper.Conv.ToDecimal(row["bill_cash"].ToString());
                        line.memo      = row["memo"].ToString();

                        ord.bill_total = line.bill_cash;

                        flag = 1;
                        break;
                    }
                }
                if (flag == 0)
                {
                    throw new Exception("表体无合法数据!");
                }
                if (runType == 1)
                {
                    IBLL.IFYOrder bll = new BLL.FYOrder();
                    string        sheet_no;
                    bll.Add(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.IFYOrder bll = new BLL.FYOrder();
                    bll.Change(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)
            {
                MsgForm.ShowFrom(ex);
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }