コード例 #1
0
        private void btn_tf_Click(object sender, EventArgs e)
        {
            #region 退费输入检查
            if (str_tjbh == "")
            {
                MessageBox.Show("请选择一条人员信息!", "提示");
                return;
            }
            if (str_tjcs == "")
            {
                MessageBox.Show("请选择一条人员信息!", "提示");
                return;
            }
            if (txt_tfyy.Text.Trim() == "")
            {
                MessageBox.Show("请输入退费原因!", "提示");
                txt_tfyy.Focus();
                return;
            }
            if (sfjlbz == "0")
            {
                MessageBox.Show("该记录没有收费,不需要退费!", "提示");
                return;
            }
            #endregion


            DialogResult dlg = MessageBox.Show("确定要退费吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            if (dlg == DialogResult.No)
            {
                return;
            }



            #region 退费金额检查
            //实际退金额
            DataTable dttf = tjdjbiz.GetSsje(sfjlbz, str_tjbh, str_tjcs);
            if (dttf.Rows.Count == 0)
            {
                return;
            }
            string stje = dttf.Rows[0]["ssje"].ToString();
            string yhlx = dttf.Rows[0]["yhlx"].ToString();
            string yhxx = dttf.Rows[0]["yhxx"].ToString();
            if (Convert.ToDecimal(stje) < ysje)
            {
                string msg = "";
                if (yhlx == "1")
                {
                    msg = "按金额优惠";
                }
                if (yhlx == "2")
                {
                    msg = "按比例优惠";
                }
                MessageBox.Show("该记录已经" + msg + "过,退费将按实收费用退费!\n 应退:" + stje, "提示");
            }
            #endregion

            #region 退费
            //未收费时,退费功能不可用
            if (Convert.ToInt16(sfjlbz) > 0)
            {
                //退费单号
                try
                {
                    tjdjBiz tjdjbiz2 = new tjdjBiz();
                    string  tfdh     = xtbiz.GetHmz("tj_tfdh", 1);
                    tjdjbiz2.TjTf(tfdh, Program.userid, Convert.ToDecimal(stje), txt_tfyy.Text.Trim(), sfjlbz);

                    string sfh = xtbiz.GetHmz("tj_sjh", 1);
                    tjdjbiz2.TjSf(sfh, str_tjbh, str_tjcs, Program.userid, -Convert.ToDecimal(stje), -Convert.ToDecimal(stje), Convert.ToInt16(yhlx), 0, sfjlbz, txt_sfbeizhu.Text.Trim());
                    tjdjbiz2.UpdateSfb(sfjlbz, str_tjbh, str_tjcs, sfh);
                    int i = tjdjbiz2.Exec_ArryList();
                    //if (i > 0)
                    //{
                    MessageBox.Show("退费成功!请收回原发票!", "提示");

                    #region 日志记录
                    loginbiz.WriteLog(this.Name.Trim(), "【" + Program.username + "】" + "在电脑【" + ma.HostName() + "】上退费成功,退费单号是:" + tfdh + ",IP:" + Program.hostip, Program.username);
                    #endregion

                    btn_query_Click(null, null);
                    dgvFyxx.DataSource = tjdjbiz.GetTjfyxx("", "");;
                    //}
                }
                catch (Exception ex)
                {
                    #region 错误日志
                    loginbiz.WriteLogErr(this.Name.Trim(), "【" + Program.username + "】" + "在电脑【" + ma.HostName() + "】上退费出现异常,错误原因:" + ex.ToString() + ",IP:" + Program.hostip, Program.username);
                    #endregion

                    MessageBox.Show(ex.ToString());
                    return;
                }
            }
            #endregion
        }