Example #1
0
        public frmInitSetting()
        {
            InitializeComponent();
            //
            foreach (Control con in this.panel1.Controls)
            {
                cons.AddClickAct.Add(con);
            }
            IBLL.ISysBLL bll = new BLL.SysBLL();
            var          lst = bll.GetParSettingList();

            txt_branch_no.Focus();
            foreach (Model.bt_par_setting item in lst)
            {
                if (item.par_id == "branch_no")
                {
                    txt_branch_no.Text           = item.par_val;
                    txt_branch_no.SelectionStart = txt_branch_no.Text.Length;
                }
                else if (item.par_id == "jh")
                {
                    txt_jh.Text           = item.par_val;
                    txt_jh.SelectionStart = txt_jh.Text.Length;
                }
            }
        }
Example #2
0
 private void btn_clear_Click(object sender, EventArgs e)
 {
     if (new YesNoForm("确定执行清库操作吗?").ShowDialog() == System.Windows.Forms.DialogResult.Yes)
     {
         var     frm = new InputNumerForm("清库密码", 0);
         decimal pwd = 0;
         if (frm.Input(out pwd) && pwd == 8686)
         {
             try
             {
                 Cursor.Current = Cursors.WaitCursor;
                 IBLL.ISysBLL bll = new BLL.SysBLL();
                 bll.clear_db();
                 new MsgForm("清库完成,将退出系统").ShowDialog();
                 System.Environment.Exit(0);
             }
             catch (Exception ex)
             {
                 Log.writeLog("frmDownload ->btn_clear_Click()", ex.ToString(), Program.oper_id);
                 new MsgForm(ex.GetMessage()).ShowDialog();
             }
             finally
             {
                 Cursor.Current = Cursors.Default;
             }
         }
     }
 }
Example #3
0
        public bool UpdateState()
        {
            try
            {
                //验证中间件版本
                string ser_ver = GetServerVer();
                if (ser_ver.Equals(GlobalData.ser_var))
                {
                    //验证数据库版本
                    IBLL.ISys bll    = new BLL.SysBLL();
                    string    db_ver = bll.Read("db_ver");
                    if (!db_ver.Equals(GlobalData.db_var))
                    {
                        throw new Exception("数据库版本错误");
                    }
                }
                else
                {
                    throw new Exception("中间件版本错误");
                }

                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.writeLog(ex);
                return(false);
            }
        }
Example #4
0
        private void Save()
        {
            CompareCon(this);

            IBLL.ISys bll = new BLL.SysBLL();
            bll.updateDic(update_dic);
        }
Example #5
0
        /// <summary>
        /// 微信扫码支付查询订单支付状态
        /// </summary>
        /// <param name="mer_key"></param>
        /// <param name="ord_id"></param>
        /// <param name="sign"></param>
        /// <param name="errId"></param>
        /// <param name="errMsg"></param>
        public void WXMicroPayQuery(string mer_id, string sheet_no, out int errId, out string errMsg)
        {
            IBLL.ISysBLL bll      = new BLL.SysBLL();
            var          wxconfig = bll.GetMerWxpayById(mer_id);

            if (wxconfig == null)
            {
                throw new Exception("未配置微信帐户");
            }
            //
            body.microquery_par par = new body.microquery_par();
            par.appid        = wxconfig.wx_appid;
            par.mch_id       = wxconfig.wx_mcid;
            par.nonce_str    = Guid.NewGuid().ToString().Replace("-", "");
            par.out_trade_no = sheet_no;

            string url     = "https://api.mch.weixin.qq.com/pay/orderquery";
            var    context = request(url, par.ToString(wxconfig.wx_paykey));
            var    parres  = new body.microquery_res(context);

            if (parres.return_code.ToLower() == "success".ToLower())
            {
                if (parres.result_code.ToLower() == "success".ToLower())
                {
                    errId  = 0;
                    errMsg = "";
                    if (parres.is_doing(parres.trade_state) == true)
                    {
                        errId  = 2;
                        errMsg = "";
                    }
                    else if (parres.is_success(parres.trade_state) == true)
                    {
                        errId  = 0;
                        errMsg = "";
                    }
                    else
                    {
                        errId  = 1;
                        errMsg = parres.trade_state + "," + parres.trade_state_desc;
                    }
                }
                else
                {
                    errId  = 2;
                    errMsg = "";
                }
            }
            else
            {
                errId  = 2;
                errMsg = "";
            }
            if (errId == 1)
            {
                LogHelper.writeLog("WXMicroPayQuery()", errMsg, mer_id, sheet_no, par.ToString(wxconfig.wx_paykey));
            }
        }
Example #6
0
        /// <summary>
        /// 微信扫码支付
        /// </summary>
        /// <param name="mer_key">常春藤商户key</param>
        /// <param name="ord_id">订单号</param>
        /// <param name="pay_amt">支付金额</param>
        /// <param name="barcode">支付码</param>
        /// <param name="branch_no">机构码</param>
        /// <param name="sign">客户端签名</param>
        /// <param name="res"></param>
        /// <param name="errMsg"></param>
        public void WXMicroPay(string mer_id, string sheet_no, decimal pay_amt, string barcode, string jh, out int errId, out string errMsg)
        {
            IBLL.ISysBLL bll = new BLL.SysBLL();

            var wxconfig = bll.GetMerWxpayById(mer_id);

            if (wxconfig == null)
            {
                throw new Exception("未配置微信帐户");
            }
            //
            body.micropay_par par = new body.micropay_par();
            par.appid            = wxconfig.wx_appid;
            par.mch_id           = wxconfig.wx_mcid;
            par.device_info      = jh;
            par.nonce_str        = Guid.NewGuid().ToString().Replace("-", "");
            par.body             = "commongoods";
            par.out_trade_no     = sheet_no;
            par.total_fee        = Convert.ToInt32(pay_amt * 100);
            par.spbill_create_ip = Appsetting.server_ip;
            par.auth_code        = barcode;

            string url = "https://api.mch.weixin.qq.com/pay/micropay";

            var context = request(url, par.ToString(wxconfig.wx_paykey));
            var parres  = new body.micropay_res(context);

            if (parres.return_code.ToLower() == "success".ToLower())
            {
                if (parres.result_code.ToLower() == "success".ToLower())
                {
                    errId  = 0;
                    errMsg = "";
                }
                else
                {
                    if (parres.is_doing(parres.err_code) == true)
                    {
                        errId  = 2;
                        errMsg = "";
                    }
                    else
                    {
                        errId  = 1;
                        errMsg = parres.err_code + "," + parres.err_code_des;
                    }
                }
            }
            else
            {
                errId  = 1;
                errMsg = parres.return_code + "," + parres.return_msg;
            }
            if (errId == 1)
            {
                LogHelper.writeLog("WXMicroPay()", "[" + errId.ToString() + "]" + errMsg, mer_id, barcode, jh, par.ToString(wxconfig.wx_paykey));
            }
        }
Example #7
0
        public void WXMicroPayCancel(string mer_id, string sheet_no, out string need_try, out string need_query, out int errId, out string errMsg)
        {
            IBLL.ISysBLL bll      = new BLL.SysBLL();
            var          wxconfig = bll.GetMerWxpayById(mer_id);

            if (wxconfig == null)
            {
                throw new Exception("未配置微信帐户");
            }
            //
            body.microcancel_par par = new body.microcancel_par();
            par.appid        = wxconfig.wx_appid;
            par.mch_id       = wxconfig.wx_mcid;
            par.nonce_str    = Guid.NewGuid().ToString().Replace("-", "");
            par.out_trade_no = sheet_no;

            var context = request(par.ToString(wxconfig.wx_paykey), mer_id, wxconfig.wx_mcid);
            var parres  = new body.microcancel_res(context);

            if (parres.return_code.ToLower() == "success".ToLower())
            {
                if (parres.result_code.ToLower() == "success".ToLower())
                {
                    need_try   = "0";
                    need_query = "0";
                    errId      = 1;
                    errMsg     = "";
                }
                else
                {
                    if (parres.recall == "Y")
                    {
                        need_try   = "1";
                        need_query = "0";
                        errId      = 0;
                        errMsg     = parres.err_code + "," + parres.err_code_des;
                    }
                    else
                    {
                        need_try   = "0";
                        need_query = "1";
                        errId      = 0;
                        errMsg     = parres.err_code + "," + parres.err_code_des;
                    }
                }
            }
            else
            {
                need_try   = "1";
                need_query = "0";
                errId      = 0;
                errMsg     = parres.return_code + "," + parres.return_msg;
            }
            if (errId == 1)
            {
                LogHelper.writeLog("WXMicroPayCancel()", errMsg, mer_id, sheet_no, par.ToString(wxconfig.wx_paykey));
            }
        }
Example #8
0
        void AliMicroCancel(string mer_id, string sheet_no, out string need_try, out string need_query, out int errId, out string errMsg)
        {
            IBLL.ISysBLL bll    = new BLL.SysBLL();
            var          config = bll.GetMerAlipayById(mer_id);

            if (config == null)
            {
                throw new Exception("未配置支付宝帐户");
            }
            //
            body.alimicrocancel_par par = new body.alimicrocancel_par();
            par.app_id       = config.app_id;
            par.method       = "alipay.trade.cancel";
            par.charset      = "utf-8";
            par.sign_type    = "RSA";
            par.timestamp    = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            par.version      = "1.0";
            par.out_trade_no = sheet_no;
            string url = "https://openapi.alipay.com/gateway.do";

            Aop.Api.IAopClient client = new Aop.Api.DefaultAopClient(url, par.app_id, config.rsa1_private);
            Aop.Api.Request.AlipayTradeCancelRequest req = new Aop.Api.Request.AlipayTradeCancelRequest();
            req.BizContent = par.biz_content();
            var response = client.Execute <Aop.Api.Response.AlipayTradeCancelResponse>(req);
            var context  = response.Body;
            var parres   = new body.alimicrocancel_res(context);

            if (parres.code == "10000")
            {
                if (parres.retry_flag == "Y")
                {
                    need_try   = "1";
                    need_query = "0";
                    errId      = 0;
                    errMsg     = parres.sub_msg;
                }
                else
                {
                    need_try   = "0";
                    need_query = "1";
                    errId      = 0;
                    errMsg     = parres.sub_msg;
                }
            }
            else
            {
                need_try   = "1";
                need_query = "0";
                errId      = 0;
                errMsg     = parres.msg;
            }

            if (errId != 0)
            {
                LogHelper.writeLog("AliMicroCancel()", errMsg, errId.ToString(), mer_id, sheet_no, par.biz_content());
            }
        }
        private void tsbSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!MyLove.PermissionsBalidation(this.Text, "04"))
                {
                    return;
                }
                if (this.tvType.SelectedNode == null)
                {
                    MsgForm.ShowFrom("请先选择操作员组");
                    return;
                }

                sa_t_oper_type oper_type = this.tvType.SelectedNode.Tag as sa_t_oper_type;

                if (oper_type.oper_type.Equals("1000"))
                {
                    MsgForm.ShowFrom("系统管理员权限不可修改");
                    return;
                }

                List <sa_t_oper_grant> grantlis = new List <sa_t_oper_grant>();
                var list = tn_dic.Where(d => d.Value.Checked).Select(d => d.Key).ToList();

                list.ForEach(t =>
                {
                    string[] strs = t.Split('_');

                    var item = grantlis.SingleOrDefault(g => g.func_id.Equals(strs[0]));

                    if (item == null)
                    {
                        grantlis.Add(new sa_t_oper_grant()
                        {
                            func_id      = strs[0],
                            grant_string = strs[1] + ";",
                            oper_id      = oper_type.oper_type,
                            update_time  = DateTime.Now,
                        });
                    }
                    else
                    {
                        item.grant_string += strs[1] + ";";
                    }
                });

                IBLL.ISys bll = new BLL.SysBLL();
                bll.SaveGrant(grantlis);

                MsgForm.ShowFrom("保存成功");
            }
            catch (Exception ex)
            {
                MsgForm.ShowFrom(ex);
            }
        }
Example #10
0
        private void tvType_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (this.tvType.SelectedNode == null)
                {
                    return;
                }

                sa_t_oper_type oper_type = this.tvType.SelectedNode.Tag as sa_t_oper_type;
                if (oper_type.oper_type.Equals("1000"))
                {
                    tsbAllCheck_Click(sender, e);
                }
                else
                {
                    IBLL.ISys bll = new BLL.SysBLL();
                    List <sa_t_oper_grant> list = bll.GetAllGrant(new sa_t_oper_grant()
                    {
                        oper_id = oper_type.oper_type
                    });

                    //清空选项
                    tsbNoCheck_Click(sender, e);

                    list.ForEach((grant) =>
                    {
                        string[] grants = grant.grant_string.Split(';');
                        foreach (string str in grants)
                        {
                            if (string.IsNullOrEmpty(str))
                            {
                                continue;
                            }

                            TreeNode tn = tn_dic[grant.func_id + "_" + str];
                            tn.Checked  = true;
                            if (tn.Parent != null)
                            {
                                UpdateParentNodes(tn.Parent);
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                MsgForm.ShowFrom(ex);
            }
        }
Example #11
0
        private void pic_continue_weight_Click(object sender, EventArgs e)
        {
            if (Program.is_continue_weight == "1")
            {
                Program.is_continue_weight = "0";
                pic_continue_weight.Image  = Properties.Resources.noweight;
            }
            else
            {
                Program.is_continue_weight = "1";
                pic_continue_weight.Image  = Properties.Resources.weight;
            }
            IBLL.ISysBLL bll = new BLL.SysBLL();
            var          lst = new List <Model.bt_par_setting>();

            lst.Add(new Model.bt_par_setting {
                par_id = "is_continue_weight", par_val = Program.is_continue_weight
            });
            bll.UpdateParSetting(lst);
        }
Example #12
0
 /// <summary>
 /// 查询订单支付宝支付状态
 /// </summary>
 /// <param name="sheet_no">单号</param>
 bool IPayBLL.QueryAliPrePay(string sheet_no, string mer_id, out string errMsg)
 {
     errMsg = "";
     try
     {
         IBLL.ISysBLL bll = new BLL.SysBLL();
         body.alipay  acc = bll.GetMerAlipayById(mer_id);
         if (acc == null)
         {
             throw new Exception("未初始化支付宝商家帐户");
         }
         Com.Alipay.AliPay alibll = new Com.Alipay.AliPay();
         var res = alibll.Alipay_Query(acc.app_id, acc.rsa1_private, acc.rsa1, sheet_no, out errMsg);
         return(res);
     }
     catch (Exception ex)
     {
         LogHelper.writeLog("PayBLL.QueryAliPrePay()", ex.ToString(), sheet_no);
         throw ex;
     }
 }
Example #13
0
        public bool verify_merchant(string mer_key, out string mer_id, out string errMsg)
        {
            IBLL.ISysBLL bll = new BLL.SysBLL();
            var          mer = bll.GetMerchantByKey(mer_key);

            if (mer == null)
            {
                mer_id = "";
                errMsg = "不存在商户";
                return(false);
            }
            if (mer.status != "1")
            {
                mer_id = "";
                errMsg = "商户已停用";
                return(false);
            }
            mer_id = mer.mer_id;
            errMsg = "";
            return(true);
        }
Example #14
0
 /// <summary>
 /// 查询订单微信支付状态
 /// </summary>
 /// <param name="sheet_no">单号</param>
 string IPayBLL.QueryWxPrePay(string sheet_no, string mer_id, out string errMsg)
 {
     DB.IDB db = new DB.DBByAutoClose(Appsetting.conn);
     errMsg = "";
     try
     {
         IBLL.ISysBLL bll = new BLL.SysBLL();
         var          acc = bll.GetMerWxpayById(mer_id);
         if (acc == null)
         {
             throw new Exception("未初始化微信商家帐户");
         }
         var wxconfig = new Wxpay.WxpayConfig(acc.wx_appid, acc.wx_secret, acc.wx_mcid, acc.wx_paykey);
         var wxorder  = new Wxpay.WxpayOrder(wxconfig);
         var res      = wxorder.QueryOrderStatusByOrderId(sheet_no, out errMsg);
         return(res);
     }
     catch (Exception ex)
     {
         LogHelper.writeLog("PayBLL.QueryWxPrePay()", ex.ToString(), sheet_no);
         throw ex;
     }
 }
Example #15
0
        private void label14_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (txt_branch_no.Text.Trim().Length == 0)
                {
                    new MsgForm("机构编码不能为空").ShowDialog();
                    return;
                }
                IBLL.ISysBLL bll = new BLL.SysBLL();
                var          lst = new List <Model.bt_par_setting>();
                lst.Add(new Model.bt_par_setting {
                    par_id = "branch_no", par_val = txt_branch_no.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "jh", par_val = txt_jh.Text
                });
                bll.UpdateParSetting(lst);
                Program.branch_no = txt_branch_no.Text;
                Program.jh        = txt_jh.Text;

                var frm = new MsgForm("初始化设置成功");
                frm.ShowDialog();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                new MsgForm(ex.GetMessage()).ShowDialog();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #16
0
        public frmParSetting()
        {
            InitializeComponent();
            //
            foreach (Control con in this.panel1.Controls)
            {
                cons.AddClickAct.Add(con);
            }
            IBLL.ISysBLL bll = new BLL.SysBLL();
            var          lst = bll.GetParSettingList();

            txt_branch_no.Focus();
            foreach (Model.bt_par_setting item in lst)
            {
                if (item.par_id == "mo_ling")
                {
                    if (item.par_val == "1")
                    {
                        radioButton2.Checked = true;
                    }
                    else if (item.par_val == "2")
                    {
                        radioButton3.Checked = true;
                    }
                    else if (item.par_val == "3")
                    {
                        radioButton4.Checked = true;
                    }
                    else
                    {
                        radioButton1.Checked = true;
                    }
                }
                else if (item.par_id == "weight_model")
                {
                    if (item.par_val == "2")
                    {
                        radioButton6.Checked = true;
                    }
                    else
                    {
                        radioButton5.Checked = true;
                    }
                }
                else if (item.par_id == "branch_no")
                {
                    txt_branch_no.Text           = item.par_val;
                    txt_branch_no.SelectionStart = txt_branch_no.Text.Length;
                }
                else if (item.par_id == "jh")
                {
                    txt_jh.Text           = item.par_val;
                    txt_jh.SelectionStart = txt_jh.Text.Length;
                }
                else if (item.par_id == "input_cus_model")
                {
                    if (item.par_val == "2")
                    {
                        radioButton8.Checked = true;
                    }
                    else
                    {
                        radioButton7.Checked = true;
                    }
                }
                else if (item.par_id == "print_count")
                {
                    txt_print_count.Text           = item.par_val;
                    txt_print_count.SelectionStart = txt_print_count.Text.Length;
                }
                else if (item.par_id == "can_input_qty")
                {
                    if (item.par_val != "1")
                    {
                        chk_input_qty.Checked = false;
                    }
                }
                else if (item.par_id == "is_continue_weight")
                {
                    if (item.par_val == "1")
                    {
                        chk_continue_weight.Checked = true;
                    }
                }
            }
        }
Example #17
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("转出账户必填!");
                }
                if (this.txtvisa2.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("转入账户必填!");
                }
                if (Helper.Conv.ToDecimal(txtcash.Text.Trim()) <= 0)
                {
                    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      = txtvisa2.Text.Trim().Split('/')[0];
                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_total   = Helper.Conv.ToDecimal(txtcash.Text.Trim());
                ord.bill_flag    = "B";
                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;

                if (runType == 1)
                {
                    IBLL.ICashOrder bll      = new BLL.CashOrder();
                    string          sheet_no = "";
                    bll.Add(ord, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.ICashOrder bll = new BLL.CashOrder();
                    bll.Change(ord);

                    IOrder ins = this;
                    ins.ShowOrder(ord.sheet_no);
                }

                Dictionary <string, object> dic = this.Tag as Dictionary <string, object>;
                this.Tag = 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;
            }
        }
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txt_sup.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("客户编码必填!");
                    return;
                }
                if (txtbranch.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("机构必填!");
                    return;
                }
                if (txtoper_date.Text.Trim() == "")
                {
                    MsgForm.ShowFrom("单据日期必填!");
                    return;
                }

                co_t_order_main         ord   = new co_t_order_main();
                List <co_t_order_child> lines = new List <co_t_order_child>();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.branch_no    = txtbranch.Text.Trim().Split('/')[0];
                ord.sup_no       = txt_sup.Text.Trim().Split('/')[0];
                ord.coin_code    = 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.order_man    = txt_order_man.Text.Split('/')[0];
                ord.trans_no     = "S";
                ord.order_status = "0";
                ord.sale_way     = "A";
                ord.p_sheet_no   = "";
                ord.approve_flag = "0";
                ord.other1       = "";
                ord.cm_branch    = "00";
                ord.approve_man  = txtapprove_man.Text.Split('/')[0];
                ord.approve_date = System.DateTime.MinValue;
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                ord.valid_date   = dtvalid_date.Text.ToDateTime();
                ord.memo         = txtmemo1.Text;
                ord.other2       = txtmemo2.Text;

                int     flag      = 0;
                int     index     = 0;
                decimal total_amt = 0;
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    ++index;
                    if (row["item_no"].ToString() != "")
                    {
                        co_t_order_child line = new co_t_order_child();
                        lines.Add(line);
                        line.sheet_no    = ord.sheet_no;
                        line.item_no     = row["item_no"].ToString();
                        line.unit_no     = row["unit_no"].ToString();
                        line.barcode     = row["barcode"].ToString();
                        line.unit_factor = 1;
                        line.discount    = row["discount"].ToDecimal();
                        line.in_price    = Helper.Conv.ToDecimal(row["in_price"].ToString());
                        line.order_qnty  = Helper.Conv.ToDecimal(row["order_qnty"].ToString());
                        line.sub_amount  = Helper.Conv.ToDecimal(row["sub_amount"].ToString());
                        line.discount    = 1;
                        line.other1      = row["other1"].ToString();
                        line.other2      = "";
                        line.voucher_no  = "";
                        line.sheet_sort  = index;
                        line.num1        = 0;
                        line.num2        = 0;
                        line.num3        = 0;
                        line.packqty     = 0;
                        line.sgqty       = 0;
                        flag             = 1;
                        total_amt       += line.order_qnty * line.in_price;
                    }
                }
                if (flag == 0)
                {
                    MsgForm.ShowFrom("请输入表单明细");
                    return;
                }
                ord.total_amount = total_amt;

                if (runType == 1)
                {
                    IBLL.IInOutBLL bll      = new BLL.InOutBLL();
                    var            sheet_no = "";
                    bll.AddSaleSSSheet(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.IInOutBLL bll = new BLL.InOutBLL();
                    bll.ChangeSaleSSSheet(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;
            }
        }
Example #19
0
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txtsup.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 (txtpay_way.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("付款方式必填");
                }
                if (txtvisa.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("账户必填");
                }
                Model.rp_t_recpay_record_info ord = new Model.rp_t_recpay_record_info();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.supcust_no   = txtsup.Text.Split('/')[0];
                ord.supcust_flag = "S";
                ord.flag_post    = "1";
                ord.total_amount = Helper.Conv.ToDecimal(txttotal_amount.Text.Trim());
                ord.free_money   = Helper.Conv.ToDecimal(txtfree_money.Text.Trim());
                ord.coin_no      = "RMB";
                ord.coin_rate    = 1;
                ord.pay_way      = txtpay_way.Text.Split('/')[0];
                ord.approve_flag = "0";
                ord.oper_id      = txtoper_man.Text.Trim().Split('/')[0];
                ord.oper_date    = Helper.Conv.ToDateTime(txtoper_date.Text.Trim());
                ord.deal_man     = txtpeople.Text.Split('/')[0];
                ord.approve_man  = "";
                ord.approve_date = DateTime.MinValue;
                ord.other1       = txtmemo.Text.Trim();
                ord.other2       = "";
                ord.other3       = "";
                ord.visa_id      = txtvisa.Text.Split('/')[0];
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                ord.cm_branch    = "00";
                ord.branch_no    = txtbranch.Text.Split('/')[0];
                ord.from_date    = DateTime.MinValue;
                ord.to_date      = DateTime.MinValue;
                ord.rc_sheet_no  = "";
                int flag = 0;
                List <Model.rp_t_recpay_record_detail> lines = new List <Model.rp_t_recpay_record_detail>();
                int     index      = 0;
                decimal pay_amt    = ord.total_amount;
                decimal free_money = ord.free_money;
                decimal get_amt    = 0;
                //应还客户金额
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    if (row["voucher_no"].ToString() != "" && row["select_flag"].ToString() == "1" && row["path"].ToString() == "-1")
                    {
                        get_amt += Conv.ToDecimal(row["pay_amount"]);
                    }
                }
                pay_amt += get_amt;
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    index++;
                    if (row["voucher_no"].ToString() != "" && pay_amt >= 0 && row["select_flag"].ToString() == "1")
                    {
                        /*
                         * if (Helper.Conv.ToDecimal(row["pay_amount"].ToString()) < 0)
                         * {
                         *  throw new Exception("第i行付款金额不正确!".Replace("i", index.ToString()));
                         * }
                         * if (Helper.Conv.ToDecimal(row["pay_free"].ToString()) < 0)
                         * {
                         *  throw new Exception("第i行免付金额不正确!".Replace("i", index.ToString()));
                         * }
                         */
                        decimal need_pay  = Conv.ToDecimal(row["pay_amount"]);
                        decimal repay_amt = 0;
                        decimal pay_fee   = 0;
                        if (row["path"].ToString() == "-1")
                        {
                            repay_amt = need_pay;
                            pay_fee   = 0;
                        }
                        else
                        {
                            if (free_money > need_pay)
                            {
                                pay_fee = need_pay;
                            }
                            else
                            {
                                pay_fee = free_money;
                                if (pay_amt > need_pay - pay_fee)
                                {
                                    repay_amt = need_pay - pay_fee;
                                }
                                else
                                {
                                    repay_amt = pay_amt;
                                }
                            }
                            free_money -= pay_fee;
                            pay_amt    -= repay_amt;
                        }
                        Model.rp_t_recpay_record_detail line = new Model.rp_t_recpay_record_detail();
                        lines.Add(line);
                        line.sheet_no       = ord.sheet_no;
                        line.voucher_no     = row["voucher_no"].ToString();
                        line.sheet_amount   = Helper.Conv.ToDecimal(row["sheet_amount"].ToString());
                        line.pay_amount     = repay_amt; // Helper.Conv.ToDecimal(row["pay_amount"].ToString());
                        line.pay_free       = pay_fee;   // Helper.Conv.ToDecimal(row["pay_free"].ToString());
                        line.memo           = row["memo"].ToString();
                        line.other1         = "";
                        line.other2         = "";
                        line.other3         = "";
                        line.num1           = 0;
                        line.num2           = 0;
                        line.num3           = 0;
                        line.pay_date       = System.DateTime.Now;
                        line.item_no        = "";
                        line.path           = ((row["path"].ToString() == "1" || row["path"].ToString() == "+") ? "+" : "-");
                        line.select_flag    = row["select_flag"].ToString();
                        line.voucher_type   = row["voucher_type"].ToString();
                        line.oper_date      = DateTime.Now;
                        line.voucher_other1 = "";
                        line.voucher_other2 = "";
                        line.order_no       = "";
                        flag = 1;
                    }
                }
                if (flag == 0)
                {
                    throw new Exception("无可结算明细!");
                }
                if (runType == 1)
                {
                    IBLL.ISupSettle bll      = new BLL.SupSettle();
                    string          sheet_no = "";
                    bll.Add(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.ISupSettle bll = new BLL.SupSettle();
                    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;
            }
        }
Example #20
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;
            }
        }
Example #21
0
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txt_trans_no.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("业务类型必填!");
                    return;
                }
                if (txtbranch.Text.Trim().Contains("/") == false)
                {
                    MsgForm.ShowFrom("机构必填!");
                    return;
                }
                if (txtoper_date.Text.Trim() == "")
                {
                    MsgForm.ShowFrom("单据日期必填!");
                    return;
                }

                ic_t_inout_store_master        ord   = new ic_t_inout_store_master();
                List <ic_t_inout_store_detail> lines = new List <ic_t_inout_store_detail>();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.trans_no     = txt_trans_no.Text.Trim().Split('/')[0];
                ord.branch_no    = txtbranch.Text.Trim().Split('/')[0];
                ord.voucher_no   = "";
                ord.supcust_no   = "";
                ord.pay_way      = "";
                ord.discount     = 1;
                ord.coin_no      = "RMB";
                ord.tax_amount   = 0;
                ord.oper_date    = Helper.Conv.ToDateTime(txtoper_date.Text.Trim());
                ord.oper_id      = txtoper_man.Text.Split('/')[0];
                ord.deal_man     = txt_deal_man.Text.Split('/')[0];
                ord.cm_branch    = "00";
                ord.other1       = txt_other3.Text.Trim();
                ord.other2       = "";
                ord.other3       = txt_other3.Text.Trim();
                ord.old_no       = txt_old_no.Text;
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                ord.sale_no      = "";
                ord.approve_flag = "0";
                ord.approve_man  = txtapprove_man.Text.Split('/')[0];
                ord.approve_date = System.DateTime.MinValue;
                ord.pay_date     = System.DateTime.MinValue;
                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() != "")
                    {
                        ic_t_inout_store_detail line = new ic_t_inout_store_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.in_qty      = Helper.Conv.ToDecimal(row["in_qty"].ToString());
                        line.orgi_price  = 0;
                        line.valid_price = Helper.Conv.ToDecimal(row["valid_price"].ToString());
                        line.cost_price  = 0;
                        line.sub_amount  = Helper.Conv.ToDecimal(row["sub_amount"].ToString());
                        line.discount    = 1;
                        line.tax         = 0;
                        line.is_tax      = "0";
                        line.valid_date  = DateTime.MinValue;
                        line.other1      = row["other1"].ToString();
                        line.other2      = "";
                        line.other3      = "";
                        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.cost_notax  = 0;
                        line.packqty     = 0;
                        line.sgqty       = 0;
                        flag             = 1;
                        total_amt       += line.in_qty * line.valid_price;
                    }
                }
                if (flag == 0)
                {
                    MsgForm.ShowFrom("请输入表单明细");
                    return;
                }
                ord.inout_amount = total_amt;
                ord.total_amount = total_amt;
                IBLL.IInOutBLL bll = new BLL.InOutBLL();
                if (runType == 1)
                {
                    var sheet_no = "";
                    bll.AddInOut(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    bll.ChangeInOut(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("frmOtherInOutSheet->Save()", ex.ToString(), txtsheet_no.Text);
                MsgForm.ShowFrom("其它出入单保存异常[" + ex.Message + "]");
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
Example #22
0
 private void LoadSetting()
 {
     IBLL.ISys bll = new BLL.SysBLL();
     setting_dic = bll.GetAllDic();
 }
Example #23
0
        string IPayBLL.Query(string mer_id, string sheet_no, string pay_type)
        {
            DB.IDB db     = new DB.DBByAutoClose(Appsetting.conn);
            string status = "0";

            try
            {
                //微信支付生成微信预支付订单
                if (pay_type == "W")
                {
                    try
                    {
                        Wxpay.MicroPay bll  = new Wxpay.MicroPay();
                        int            eid  = 0;
                        string         emsg = "";
                        bll.WXMicroPayQuery(mer_id, sheet_no, out eid, out emsg);
                        if (eid == 0)
                        {
                            status = "1";
                        }
                        else if (eid == 1)
                        {
                            status = "2";
                            throw new Exception("微信扫码支付失败[" + eid.ToString() + "]:" + emsg);
                        }
                        else
                        {
                            status = "0";
                        }
                    }
                    catch (Exception ex2)
                    {
                        throw ex2;
                    }
                }
                else if (pay_type == "Z")
                {
                    try
                    {
                        IBLL.ISysBLL bll = new BLL.SysBLL();
                        body.alipay  acc = bll.GetMerAlipayById(mer_id);
                        if (acc == null)
                        {
                            throw new Exception("未初始化支付宝商家帐户");
                        }
                        Com.Alipay.AliPay alibll = new Com.Alipay.AliPay();
                        var emsg = "";
                        var res  = alibll.Alipay_Query(acc.app_id, acc.rsa1_private, acc.rsa1, sheet_no, out emsg);

                        if (!res)
                        {
                            throw new Exception("支付宝扫码支付失败:" + emsg);
                        }
                        else
                        {
                            status = "1";
                        }
                    }
                    catch (Exception ex2)
                    {
                        throw ex2;
                    }
                }
                //
                if (status != "1")
                {
                    string sql  = "update ot_pay_record set status=@status where sheet_no=@sheet_no ";
                    var    pars = new System.Data.SqlClient.SqlParameter[]
                    {
                        new System.Data.SqlClient.SqlParameter("@sheet_no", sheet_no),
                        new System.Data.SqlClient.SqlParameter("@status", status)
                    };

                    db.ExecuteScalar(sql, pars);
                }
                return(status);
            }
            catch (Exception ex)
            {
                LogHelper.writeLog("PayBLL.Query()", ex.ToString(), sheet_no, mer_id, pay_type);
                throw ex;
            }
        }
Example #24
0
        private void btn_reprint_Click(object sender, EventArgs e)
        {
            var c_row = dataGridView1.CurrentRow;

            if (c_row != null && c_row.Tag != null && c_row.Tag.ToString() != "")
            {
                var sheet_no = c_row.Tag.ToString();
                //准备打印表格
                DataTable dt = new DataTable();
                dt.Columns.Add("行号");
                dt.Columns.Add("销售单号");
                dt.Columns.Add("客户");
                dt.Columns.Add("操作员");
                dt.Columns.Add("日期");
                dt.Columns.Add("货号");
                dt.Columns.Add("商品名称");
                dt.Columns.Add("规格");
                dt.Columns.Add("单位");
                dt.Columns.Add("数量");
                dt.Columns.Add("单价");
                dt.Columns.Add("金额");
                dt.Columns.Add("合计数量");
                dt.Columns.Add("合计金额");
                dt.Columns.Add("付款方式");
                dt.Columns.Add("实付金额");
                dt.Columns.Add("抹零金额");
                dt.Columns.Add("整单折扣");

                IBLL.ISaleData bll   = new BLL.SaleData();
                DataTable      lines = new DataTable();
                decimal        ml    = 0;
                var            ord   = bll.GetSaleSheetMasterDetail(sheet_no, out lines, out ml);
                decimal        amt   = 0; //单据总金额
                decimal        qty   = 0; //单据总数量
                int            index = 0;
                if (ord != null && lines.Rows.Count > 0)
                {
                    string pay_way_str = "挂账/预付";
                    if (ord.pay_way == "A")
                    {
                        pay_way_str = "现结-现金";
                    }
                    else if (ord.pay_way == "W")
                    {
                        pay_way_str = "现结-微信";
                    }
                    else if (ord.pay_way == "Z")
                    {
                        pay_way_str = "现结-支付宝";
                    }

                    foreach (DataRow dr in lines.Rows)
                    {
                        ++index;
                        //待打印表单处理
                        DataRow row = dt.NewRow();
                        row["行号"]   = index.ToString();
                        row["销售单号"] = ord.sheet_no;
                        row["客户"]   = ord.cust_no;
                        row["操作员"]  = ord.oper_id;
                        row["日期"]   = ord.oper_date.ToString("yyyy-MM-dd");
                        row["货号"]   = dr["item_subno"].ToString();
                        row["商品名称"] = dr["item_name"].ToString();
                        row["规格"]   = dr["item_size"].ToString();
                        row["单位"]   = dr["unit_no"].ToString();
                        row["数量"]   = Conv.ToDecimal(dr["sale_qnty"]).ToString("F2");
                        row["单价"]   = Conv.ToDecimal(dr["real_price"]).ToString("F2");
                        row["金额"]   = Conv.ToDecimal(dr["sale_money"]).ToString("F2");
                        row["付款方式"] = pay_way_str;
                        row["实付金额"] = ord.real_amount.ToString("F2");
                        row["抹零金额"] = ml.ToString("F2");
                        if (ord.discount != 0)
                        {
                            row["整单折扣"] = (ord.discount * 100) + "折";
                        }
                        else
                        {
                            row["整单折扣"] = "无折扣";
                        }
                        dt.Rows.Add(row);
                        amt += Conv.ToDecimal(dr["sale_money"]);
                        qty += Conv.ToDecimal(dr["sale_qnty"]);
                    }
                    foreach (DataRow row in dt.Rows)
                    {
                        row["合计数量"] = qty.ToString("F2");
                        row["合计金额"] = amt.ToString("F2");
                    }
                }
                //打印
                try
                {
                    IBLL.ISysBLL sbll = new BLL.SysBLL();
                    sbll.WritePrintLog(ord.sheet_no);
                    printXSCK printXsck = new printXSCK(dt);
                    printXsck.print();
                }
                catch (Exception ex)
                {
                    Log.writeLog("btn_reprint_Click()", ex.ToString(), sheet_no);
                }
            }
        }
Example #25
0
        /// <summary>
        /// 微信扫码支付
        /// </summary>
        /// <param name="mer_key">常春藤商户id</param>
        /// <param name="ord_id">订单号</param>
        /// <param name="pay_amt">支付金额</param>
        /// <param name="barcode">支付码</param>
        /// <param name="branch_no">机构码</param>
        /// <param name="sign">客户端签名</param>
        /// <param name="res"></param>
        /// <param name="errMsg"></param>
        void AliMicroPay(string mer_id, string sheet_no, decimal pay_amt, string barcode, string jh, out int errId, out string errMsg)
        {
            IBLL.ISysBLL bll    = new BLL.SysBLL();
            var          config = bll.GetMerAlipayById(mer_id);

            if (config == null)
            {
                throw new Exception("未配置支付宝帐户");
            }
            //
            body.alimicropay_par par = new body.alimicropay_par();
            par.app_id       = config.app_id;
            par.method       = "alipay.trade.pay";
            par.charset      = "utf-8";
            par.sign_type    = "RSA";
            par.timestamp    = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            par.version      = "1.0";
            par.out_trade_no = sheet_no;
            par.scene        = "bar_code";
            par.auth_code    = barcode;
            par.subject      = "commongoods";
            par.total_amount = pay_amt.ToString("0.00");
            par.store_id     = jh;
            string url = "https://openapi.alipay.com/gateway.do";

            Aop.Api.IAopClient client = new Aop.Api.DefaultAopClient(url, par.app_id, config.rsa1_private);
            Aop.Api.Request.AlipayTradePayRequest req = new Aop.Api.Request.AlipayTradePayRequest();
            req.BizContent = par.biz_content();
            var response = client.Execute <Aop.Api.Response.AlipayTradePayResponse>(req);
            var context  = response.Body;
            var parres   = new body.alimicropay_res(context);

            if (parres.code == "10000")
            {
                errId  = 0;
                errMsg = "";
            }
            else if (parres.code == "20000" || parres.code == "20001" || parres.code == "40001" || parres.code == "40002" || parres.code == "40006")//出错
            {
                errId  = 1;
                errMsg = parres.code + "," + parres.msg + "," + parres.sub_code + "," + parres.sub_msg;
            }
            else if (parres.code == "40004")
            {
                if (parres.is_doing(parres.sub_code) == true)
                {
                    errId  = 2;
                    errMsg = "";
                }
                else
                {
                    errId  = 1;
                    errMsg = parres.sub_code + "," + parres.sub_msg;
                }
            }
            else//未知错误
            {
                errId  = 2;
                errMsg = "";
            }
            if (errId == 1)
            {
                LogHelper.writeLog("AliMicroPay()", errMsg, mer_id, sheet_no, par.biz_content());
            }
        }
Example #26
0
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txtcus.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("客户必填!");
                }
                if (txtbranch.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("机构必填!");
                }
                if (txtoper_date.Text.Trim() == "")
                {
                    throw new Exception("单据日期必填!");
                }
                this.editGrid1.DataSource.ClearTable("kk_no");
                if (this.editGrid1.DataSource.Rows.Count > 1)
                {
                    throw new Exception("只允许录入一行!");
                }

                Model.rp_t_supcust_fy_master ord = new Model.rp_t_supcust_fy_master();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.supcust_no   = txtcus.Text.Trim().Split('/')[0];
                ord.supcust_flag = "S";
                ord.pay_date     = System.DateTime.Now;
                ord.old_no       = txtold_no.Text.Trim();
                ord.oper_id      = this.txtoper_man.Text.Trim().Split('/')[0];
                ord.oper_date    = Helper.Conv.ToDateTime(this.txtoper_date.Text);
                ord.approve_flag = "0";
                ord.approve_man  = "";
                ord.approve_date = System.DateTime.MinValue;
                ord.is_payed     = "0";
                ord.sale_man     = txtpeople.Text.Trim().Split('/')[0];
                ord.branch_no    = txtbranch.Text.Trim().Split('/')[0];
                ord.cm_branch    = "00";
                ord.other1       = txtmemo.Text.Trim();
                ord.other2       = "";
                ord.other3       = "";
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                ord.visa_id      = txtvisa.Text.Trim().Split('/')[0];
                ord.is_over      = "0";
                ord.total_amount = 0;
                ord.paid_amount  = 0;
                ord.pay_way      = "";
                ord.pay_name     = "";
                int flag = 0;
                List <Model.rp_t_supcust_fy_detail> lines = new List <Model.rp_t_supcust_fy_detail>();
                int index = 0;
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    index++;
                    if (row["kk_no"].ToString() != "")
                    {
                        if (Helper.Conv.ToDecimal(row["kk_cash"].ToString()) <= 0)
                        {
                            throw new Exception("第i行费用金额不正确!".Replace("i", index.ToString()));
                        }
                        Model.rp_t_supcust_fy_detail line = new Model.rp_t_supcust_fy_detail();
                        lines.Add(line);
                        line.sheet_no    = ord.sheet_no;
                        line.kk_no       = row["kk_no"].ToString();
                        line.kk_cash     = Helper.Conv.ToDecimal(row["kk_cash"].ToString());
                        line.other1      = row["other1"].ToString();
                        line.other2      = "";
                        line.other3      = "";
                        line.num1        = 0;
                        line.num2        = 0;
                        line.num3        = 0;
                        ord.total_amount = line.kk_cash;
                        if (row["pay_kind"].ToString() == "0" || row["pay_kind"].ToString() == "-")
                        {
                            ord.pay_type = "-";
                        }
                        else
                        {
                            ord.pay_type = "+";
                        }
                        flag = 1;
                    }
                }
                if (flag == 0)
                {
                    throw new Exception("表体无合法数据!");
                }
                if (runType == 1)
                {
                    IBLL.ISupFY bll = new BLL.SupFY();
                    string      sheet_no;
                    bll.Add(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.ISupFY bll = new BLL.SupFY();
                    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;
            }
        }
Example #27
0
        void IPayBLL.MicroPay(string ori_sheet_no, string mer_id, string jh, string pay_type, decimal pay_amt, string barcode, out string sheet_no, out string status, out int errId, out string errMsg)
        {
            DB.IDB db = new DB.DBByAutoClose(Appsetting.conn);
            sheet_no = "";
            errId    = 0;
            errMsg   = "";
            status   = "0";
            try
            {
                sheet_no = mer_id + create_sheet_no();//商家编号+14位单号
                //微信支付生成微信预支付订单
                if (pay_type == "W")
                {
                    try
                    {
                        Wxpay.MicroPay bll  = new Wxpay.MicroPay();
                        int            eid  = 0;
                        string         emsg = "";
                        bll.WXMicroPay(mer_id, sheet_no, pay_amt, barcode, jh, out eid, out emsg);
                        errId  = eid;
                        errMsg = emsg;
                        if (eid == 0)
                        {
                            status = "1";
                        }
                        else if (eid == 1)
                        {
                            status = "2";
                            throw new Exception("微信扫码支付失败[" + eid.ToString() + "]:" + errMsg);
                        }
                        else
                        {
                            status = "0";
                        }
                    }
                    catch (Exception ex2)
                    {
                        throw ex2;
                    }
                }
                else if (pay_type == "Z")
                {
                    try
                    {
                        IBLL.ISysBLL bll = new BLL.SysBLL();
                        body.alipay  acc = bll.GetMerAlipayById(mer_id);
                        if (acc == null)
                        {
                            throw new Exception("未初始化支付宝商家帐户");
                        }
                        Com.Alipay.AliPay alibll = new Com.Alipay.AliPay();
                        var emsg = "";
                        var res  = alibll.Alipay_BarcodePay(acc.app_id, acc.rsa1_private, acc.rsa1, sheet_no, "commongoods", pay_amt, barcode, acc.pid, out emsg);
                        status = "1";
                        if (!res)
                        {
                            status = "2";
                            errId  = -1;
                            errMsg = emsg;
                            throw new Exception("支付宝扫码支付失败:" + emsg);
                        }
                    }
                    catch (Exception ex2)
                    {
                        throw ex2;
                    }
                }
                //
                string sql = "insert into ot_pay_record(sheet_no,mer_id,jh,pay_type,pay_scene,pay_amt,status,create_time,ori_sheet_no)";
                sql += "values(@sheet_no,@mer_id,@jh,@pay_type,@pay_scene,@pay_amt,@status,getdate(),@ori_sheet_no) ";
                var pars = new System.Data.SqlClient.SqlParameter[]
                {
                    new System.Data.SqlClient.SqlParameter("@sheet_no", sheet_no),
                    new System.Data.SqlClient.SqlParameter("@ori_sheet_no", ori_sheet_no),
                    new System.Data.SqlClient.SqlParameter("@mer_id", mer_id),
                    new System.Data.SqlClient.SqlParameter("@jh", jh),
                    new System.Data.SqlClient.SqlParameter("@pay_type", pay_type),
                    new System.Data.SqlClient.SqlParameter("@pay_amt", pay_amt),
                    new System.Data.SqlClient.SqlParameter("@status", status),
                    new System.Data.SqlClient.SqlParameter("@pay_scene", "barcode_pay")
                };

                db.ExecuteScalar(sql, pars);
            }
            catch (Exception ex)
            {
                LogHelper.writeLog("PayBLL.MicroPay()", ex.ToString(), sheet_no, ori_sheet_no, mer_id, pay_type, jh, pay_amt.ToString());
                throw ex;
            }
        }
Example #28
0
        private void label14_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (txt_branch_no.Text.Trim().Length == 0)
                {
                    new MsgForm("机构编码不能为空").ShowDialog();
                    return;
                }
                string mo_ling         = "0";
                string weight_model    = "1";
                string input_cus_model = "1";
                if (radioButton2.Checked)
                {
                    mo_ling = "1";
                }
                else if (radioButton3.Checked)
                {
                    mo_ling = "2";
                }
                else if (radioButton4.Checked)
                {
                    mo_ling = "3";
                }

                if (radioButton6.Checked)
                {
                    weight_model = "2";
                }

                if (radioButton8.Checked)
                {
                    input_cus_model = "2";
                }

                var can_input_qty = "1";
                if (!chk_input_qty.Checked)
                {
                    can_input_qty = "0";
                }

                var is_continue_weight = "0";
                if (chk_continue_weight.Checked)
                {
                    is_continue_weight = "1";
                }

                IBLL.ISysBLL bll = new BLL.SysBLL();
                var          lst = new List <Model.bt_par_setting>();
                lst.Add(new Model.bt_par_setting {
                    par_id = "mo_ling", par_val = mo_ling
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "weight_model", par_val = weight_model
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "branch_no", par_val = txt_branch_no.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "jh", par_val = txt_jh.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "input_cus_model", par_val = input_cus_model
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "print_count", par_val = txt_print_count.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "can_input_qty", par_val = can_input_qty
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "is_continue_weight", par_val = is_continue_weight
                });
                bll.UpdateParSetting(lst);
                Program.mo_ling            = mo_ling;
                Program.weight_model       = weight_model;
                Program.branch_no          = txt_branch_no.Text;
                Program.jh                 = txt_jh.Text;
                Program.input_cus_model    = input_cus_model;
                Program.print_count        = Conv.ToInt(txt_print_count.Text);
                Program.can_input_qty      = can_input_qty;
                Program.is_continue_weight = is_continue_weight;
                if (!SoftUpdate.PermissionsBalidation())
                {
                    IBLL.IClientBLL bll2   = new BLL.ClientBLL();
                    int             errId  = 0;
                    string          errMsg = "";
                    bll2.DownLoadOper(out errId, out errMsg);
                }

                var frm = new MsgForm("修改参数设置成功");
                frm.ShowDialog();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                new MsgForm(ex.GetMessage()).ShowDialog();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #29
0
        /// <summary>
        /// 结算提交订单
        /// </summary>
        /// <param name="flow_no">收银单号</param>
        /// <param name="mer_id">商家id</param>
        /// <param name="jh">机台</param>
        /// <param name="pay_type">支付方式: W微信支付; Z支付宝支付</param>
        /// <param name="pay_amt">支付金额</param>
        /// <param name="prepay_id">微信预支付id</param>
        /// <param name="qrcode_url">微信/支付宝支付二维码内容</param>
        void IPayBLL.CreatePrePay(string ori_sheet_no, string mer_id, string jh, string pay_type, decimal pay_amt, out string sheet_no, out string prepay_id, out string qrcode_url)
        {
            DB.IDB db = new DB.DBByAutoClose(Appsetting.conn);
            sheet_no   = "";
            prepay_id  = "";
            qrcode_url = "";
            try
            {
                sheet_no = mer_id + create_sheet_no();//商家编号+14位单号
                //微信支付生成微信预支付订单
                if (pay_type == "W")
                {
                    try
                    {
                        IBLL.ISysBLL bll = new BLL.SysBLL();
                        body.wxpay   acc = bll.GetMerWxpayById(mer_id);
                        if (acc == null)
                        {
                            throw new Exception("未初始化微信商家帐户");
                        }
                        var wxconfig = new Wxpay.WxpayConfig(acc.wx_appid, acc.wx_secret, acc.wx_mcid, acc.wx_paykey);
                        var wxorder  = new Wxpay.WxpayOrder(wxconfig);
                        var errMsg   = "";
                        var res      = wxorder.Pay4Qrcode(Appsetting.pay_notify_url, sheet_no, pay_amt, "commongoods", Appsetting.server_ip, out errMsg, out prepay_id, out qrcode_url);
                        if (!res)
                        {
                            LogHelper.writeLog("PayBLL.CreatePrePay(1)", "微信预付账单异常", acc.wx_appid, acc.wx_secret, acc.wx_mcid, acc.wx_paykey, sheet_no, Appsetting.pay_notify_url, pay_amt.ToString(), Appsetting.server_ip, errMsg, prepay_id, qrcode_url);
                            throw new Exception("微信预付账单生成失败:" + errMsg);
                        }
                    }
                    catch (Exception ex2)
                    {
                        throw ex2;
                    }
                }
                else if (pay_type == "Z")
                {
                    try
                    {
                        IBLL.ISysBLL bll = new BLL.SysBLL();
                        body.alipay  acc = bll.GetMerAlipayById(mer_id);
                        if (acc == null)
                        {
                            throw new Exception("未初始化支付宝商家帐户");
                        }
                        Com.Alipay.AliPay alibll = new Com.Alipay.AliPay();
                        var errMsg = "";
                        var res    = alibll.Alipay_PreCreate(acc.app_id, acc.rsa1_private, acc.rsa1, sheet_no, "commongoods", pay_amt, acc.pid, out qrcode_url, out errMsg);
                        if (!res)
                        {
                            throw new Exception("支付宝预付账单生成失败:" + errMsg);
                        }
                    }
                    catch (Exception ex2)
                    {
                        throw ex2;
                    }
                }
                //
                string sql = "insert into ot_pay_record(sheet_no,mer_id,jh,pay_type,pay_scene,pay_amt,status,create_time,ori_sheet_no)";
                sql += "values(@sheet_no,@mer_id,@jh,@pay_type,@pay_scene,@pay_amt,'0',getdate(),@ori_sheet_no) ";
                var pars = new System.Data.SqlClient.SqlParameter[]
                {
                    new System.Data.SqlClient.SqlParameter("@sheet_no", sheet_no),
                    new System.Data.SqlClient.SqlParameter("@ori_sheet_no", ori_sheet_no),
                    new System.Data.SqlClient.SqlParameter("@mer_id", mer_id),
                    new System.Data.SqlClient.SqlParameter("@jh", jh),
                    new System.Data.SqlClient.SqlParameter("@pay_type", pay_type),
                    new System.Data.SqlClient.SqlParameter("@pay_amt", pay_amt),
                    new System.Data.SqlClient.SqlParameter("@pay_scene", "pre_pay")
                };

                db.ExecuteScalar(sql, pars);
            }
            catch (Exception ex)
            {
                LogHelper.writeLog("PayBLL.CreatePrePay()", ex.ToString(), sheet_no, ori_sheet_no, mer_id, pay_type, jh, pay_amt.ToString());
                throw ex;
            }
        }
        void IOrder.Save()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                if (txtbranch.Text.Trim().Contains("/") == false)
                {
                    throw new Exception("机构必填!");
                }
                if (txtoper_date.Text.Trim() == "")
                {
                    throw new Exception("单据日期必填!");
                }
                pm_t_flow_main ord = new pm_t_flow_main();
                List <pm_t_price_flow_detial> lines = new List <pm_t_price_flow_detial>();
                ord.sheet_no     = txtsheet_no.Text.Trim();
                ord.branch_no    = txtbranch.Text.Trim().Split('/')[0];
                ord.vip_type     = "";
                ord.price_type   = "1";
                ord.oper_date    = Helper.Conv.ToDateTime(txtoper_date.Text.Trim());
                ord.oper_id      = txtoper_man.Text.Split('/')[0];
                ord.approve_flag = "0";
                ord.memo         = txtmemo.Text.Trim();
                ord.other1       = "";
                ord.other2       = "";
                ord.other3       = "";
                ord.cm_branch    = "00";
                ord.start_date   = System.DateTime.MinValue;
                ord.end_date     = System.DateTime.MinValue;
                ord.start_time   = "";
                ord.end_time     = "";
                ord.buy_amt      = 0;
                ord.add_amt      = 0;
                ord.deal_man     = txtpeople.Text.Split('/')[0];
                ord.approve_man  = txtapprove_man.Text.Split('/')[0];
                ord.approve_date = System.DateTime.MinValue;
                ord.num1         = 0;
                ord.num2         = 0;
                ord.num3         = 0;
                int flag = 0;
                foreach (DataRow row in editGrid1.DataSource.Rows)
                {
                    if (row["item_no"].ToString() != "")
                    {
                        pm_t_price_flow_detial line = new pm_t_price_flow_detial();
                        lines.Add(line);
                        line.sheet_no   = ord.sheet_no;
                        line.item_no    = row["item_no"].ToString();
                        line.price_type = ord.price_type;
                        line.start_date = ord.start_date;
                        line.end_date   = ord.end_date;
                        line.discount   = 0;
                        line.buy_qnty   = 0;
                        line.other1     = "";
                        line.other2     = "";
                        line.other3     = "";
                        line.start_time = "";
                        line.end_time   = "";
                        line.stock_qty  = 0;
                        line.num1       = 0;
                        line.num2       = 0;
                        line.num3       = 0;

                        line.old_price  = Helper.Conv.ToDecimal(row["old_price"].ToString());
                        line.old_price2 = Helper.Conv.ToDecimal(row["old_price2"].ToString());
                        line.old_price3 = Helper.Conv.ToDecimal(row["old_price3"].ToString());

                        line.new_price  = string.IsNullOrEmpty(row["new_price"].ToString()) ? line.old_price : Helper.Conv.ToDecimal(row["new_price"].ToString());
                        line.new_price2 = string.IsNullOrEmpty(row["new_price2"].ToString()) ? line.old_price2 : Helper.Conv.ToDecimal(row["new_price2"].ToString());
                        line.new_price3 = string.IsNullOrEmpty(row["new_price3"].ToString()) ? line.old_price3 : Helper.Conv.ToDecimal(row["new_price3"].ToString());

                        flag = 1;
                    }
                }
                if (flag == 0)
                {
                    throw new Exception("表体无合法数据!");
                }
                if (runType == 1)
                {
                    IBLL.ICusPriceOrder bll = new BLL.CusPriceOrderBLL();
                    string sheet_no;
                    bll.Add(ord, lines, out sheet_no);
                    IOrder ins = this;
                    ins.ShowOrder(sheet_no);
                }
                else if (runType == 2)
                {
                    IBLL.ICusPriceOrder bll = new BLL.CusPriceOrderBLL();
                    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;
            }
        }