using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using LYFZ.Helper;
using LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm;
namespace LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm
{
public partial class GoldCardCashSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.GoldCardCashSuperSmallForm
{
LYFZ.BLL.BLL_ErpMemberCard mcbll = new LYFZ.BLL.BLL_ErpMemberCard();
LYFZ.BLL.BLL_ErpMemberCardTakeCash mctcbll = new BLL.BLL_ErpMemberCardTakeCash();
LYFZ.BLL.BLL_ErpMemberCardAmountChangeLOG mcplogbll = new BLL.BLL_ErpMemberCardAmountChangeLOG();
LYFZ.BLL.BLL_ErpMemberCardRechargeDepositRecord bllDepositRecord = new BLL.BLL_ErpMemberCardRechargeDepositRecord();
BLL.BLL_ErpMemberCardRechargeDeposit bllDeposit = new BLL.BLL_ErpMemberCardRechargeDeposit();
public GoldCardCashSuperSmallForm()
{
}
public string SaveType = "会员卡提现";
///
/// 会员卡编号
///
public string StrNumber;
///
/// 会员卡号
///
public string CradNumber;
///
/// 持卡人
///
public string CradName;
///
/// 可取现金
///
public string AdvisableCash;
///
/// 是否保存
///
public bool IsSaveed = false;
///
/// 窗体加载事件
///
///
///
protected override void GoldCardCashSuperSmallForm_Load(object sender, EventArgs e)
{
txtHolders.Text = CradName;
txtCradNumber.Text = CradNumber;
txtDesirableCash.Text = AdvisableCash;
//txtCashAmount.Text = AdvisableCash;
if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Account.ToLower() == LYFZ.AuthorizeUserName.AdministratorsName)
{
if (Convert.ToDecimal(this.txtDesirableCash.Text) > 0)
{ this.txtTouchAccount.ReadOnly = false; }
else { this.txtTouchAccount.ReadOnly = true; }
}
else { this.txtTouchAccount.ReadOnly = true; }
if(SaveType.Equals("会员卡提现"))
{
this.Text = "提现";
DataTable dtDeposit = bllDeposit.GetList(" Mcrd_CardNumber = '" + StrNumber + "' and Mcrd_BComplete = 0 ").Tables[0];
if (dtDeposit.Rows.Count>0)
{
Model.Model_ErpMemberCardRechargeDeposit rechargeModel = bllDeposit.GetModel(dtDeposit.Rows[0]);
decimal havePayValue = bllDepositRecord.GetHavePayRecordAmount(rechargeModel.Mcrd_CardNumber, rechargeModel.Mcrd_RechargeNumber);
labCanNotCash.Text = "不可提现:" + " " + havePayValue + "(充值定金)";
txtDesirableCash.Text = (Convert.ToDecimal(AdvisableCash) - havePayValue).ToString("0.00");
labCanNotCash.Visible = true;
}
}
else if (SaveType.Equals("充值定金退款"))
{
this.Text = "充值定金退款";
labelEx7.Visible = false;
txtTouchAccount.Visible = false;
tb_DisInfo.Visible = true;
DataTable dtDeposit = bllDeposit.GetList(" Mcrd_CardNumber = '" + StrNumber + "' and Mcrd_BComplete = 0 ").Tables[0];
if (dtDeposit.Rows.Count > 0)
{
Model.Model_ErpMemberCardRechargeDeposit rechargeModel = bllDeposit.GetModel(dtDeposit.Rows[0]);
decimal PaytoCardValue = bllDepositRecord.GetHavePayRecordAmount(rechargeModel.Mcrd_CardNumber, rechargeModel.Mcrd_RechargeNumber);
decimal DepositValue = bllDepositRecord.GetDepositRecordAmount(rechargeModel.Mcrd_CardNumber, rechargeModel.Mcrd_RechargeNumber);
txtDesirableCash.Text = (PaytoCardValue + DepositValue).ToString("0.00");
txtCashAmount.Text = (PaytoCardValue + DepositValue).ToString("0.00");
txtCashAmount.ReadOnly = true;
}
else
{
MessageBoxCustom.Show("未缴纳定金,无需退款");
txtDesirableCash.Text = "0";
txtCashAmount.Text = "0";
txtCashAmount.ReadOnly = true;
}
labelEx3.Text = "退款现金:";
labelEx6.Text = "退款金额";
labelEx4.Text = "退款金额:";
}
}
///
/// 关闭窗体后发生事件
///
///
///
protected override void GoldCardCashSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e)
{
GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner;
if (frm1 != null)
{
frm1.RefreshParentForm = IsSaveed;
}
}
///
/// 保存
///
///
///
protected override void btnSave_Click(object sender, EventArgs e)
{
List clist = new List();
LYFZ.Model.Model_ErpMemberCard MCrad = mcbll.GetModel("Mc_Number", this.StrNumber);
DateTime StrTime = SDateTime.Now;
string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
if (SaveType.Equals("会员卡提现"))
{
if (txtCashAmount.Text.Trim() != "")
{
if (LYFZ.Command.Command_Validate.IsNumeric(txtCashAmount.Text.Trim()) == false)
{ MessageBoxCustom.Show("取现金额输入错误,取现金额只能输入整数或小数"); txtCashAmount.Text = ""; return; }
if (Convert.ToDecimal(this.txtCashAmount.Text.Trim()) > Convert.ToDecimal(this.txtDesirableCash.Text.Trim()))
{ MessageBoxCustom.Show("可取现金额不足"); return; }
decimal BeforeMoney = MCrad.Mc_Money;
if (this.txtTouchAccount.Text.Trim() == "")
{ MCrad.Mc_Money = MCrad.Mc_Money - Convert.ToDecimal(this.txtCashAmount.Text.Trim()); }
else
{
MCrad.Mc_Money = MCrad.Mc_Money - Convert.ToDecimal(this.txtCashAmount.Text) - Convert.ToDecimal(this.txtTouchAccount.Text);
MCrad.Mc_TotalTouchAccount = MCrad.Mc_TotalTouchAccount + Convert.ToDecimal(this.txtTouchAccount.Text);
MCrad.Mc_TouchAccount = Convert.ToDecimal(this.txtTouchAccount.Text);
}
MCrad.Mc_UpdateDateTime = StrTime;
MCrad.Mc_UpdateName = StrUserName;
clist.Add(mcbll.GetUpdateCommandInfo(MCrad));
decimal TouchAccount = 0;
if (this.txtTouchAccount.Text.Trim() != "")
{ TouchAccount = Convert.ToDecimal(this.txtTouchAccount.Text); }
LYFZ.Model.Model_ErpMemberCardAmountChangeLOG MCardLOG = new Model.Model_ErpMemberCardAmountChangeLOG();
MCardLOG.Mcacl_Type = "1";
MCardLOG.Mcacl_Number = this.StrNumber;
MCardLOG.Mcacl_OriginalAmount = BeforeMoney;
MCardLOG.Mcacl_ExistingAmount = BeforeMoney - (Convert.ToDecimal(txtCashAmount.Text.Trim()) + TouchAccount);
MCardLOG.Mcacl_UseAmount = Convert.ToDecimal(txtCashAmount.Text.Trim()) + TouchAccount;
if (this.txtTouchAccount.Text.Trim() == "")
{ MCardLOG.Mcacl_Remark = "主卡" + this.txtCradNumber.Text.Trim() + "提现金额为:" + txtCashAmount.Text.Trim() + "元"; }
else
{ MCardLOG.Mcacl_Remark = "主卡" + this.txtCradNumber.Text.Trim() + "提现金额为:" + txtCashAmount.Text.Trim() + "元,抹帐:" + TouchAccount; }
MCardLOG.Mcacl_CreateDatetime = StrTime;
MCardLOG.Mcacl_CreateName = StrUserName;
clist.Add(mcplogbll.GetAddCommandInfo(MCardLOG));
if (!string.IsNullOrEmpty(txtCashAmount.Text.Trim()))
{
LYFZ.Model.Model_ErpMemberCardTakeCash modelTakeCash = new Model.Model_ErpMemberCardTakeCash();
modelTakeCash.Mctkc_Number = this.StrNumber;
modelTakeCash.Mctkc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
modelTakeCash.Mctkc_TakeCashAmount = Convert.ToDecimal(txtCashAmount.Text.Trim());
modelTakeCash.Mctkc_AuditStatus = "未审核";
modelTakeCash.Mctkc_AuditName = "";
modelTakeCash.Mctkc_CreateDatetime = StrTime;
modelTakeCash.Mctkc_CreateName = StrUserName;
modelTakeCash.Mctkc_TakeCashType = "提现";
modelTakeCash.Mctkc_Remark = tb_DisInfo.Text;
clist.Add(mctcbll.GetAddCommandInfo(modelTakeCash));
}
if (!string.IsNullOrEmpty(this.txtTouchAccount.Text.Trim()))
{
LYFZ.Model.Model_ErpMemberCardTakeCash modelTakeCash = new Model.Model_ErpMemberCardTakeCash();
modelTakeCash.Mctkc_Number = this.StrNumber;
modelTakeCash.Mctkc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
modelTakeCash.Mctkc_TakeCashAmount = Convert.ToDecimal(txtTouchAccount.Text.Trim());
modelTakeCash.Mctkc_AuditStatus = "未审核";
modelTakeCash.Mctkc_AuditName = "";
modelTakeCash.Mctkc_CreateDatetime = StrTime;
modelTakeCash.Mctkc_CreateName = StrUserName;
modelTakeCash.Mctkc_TakeCashType = "抹帐";
modelTakeCash.Mctkc_Remark = tb_DisInfo.Text;
clist.Add(mctcbll.GetAddCommandInfo(modelTakeCash));
}
if (clist.Count > 0)
{
if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
{
MessageBoxCustom.Show("提现成功");
IsSaveed = true;
this.Close();
}
else
{ MessageBoxCustom.Show("提现失败"); }
}
}
}
else if (SaveType.Equals("充值定金退款"))
{
if (txtCashAmount.Text.Trim() != "")
{
DataTable dtDeposit = bllDeposit.GetList(" Mcrd_CardNumber = '" + StrNumber + "' and Mcrd_BComplete = 0 ").Tables[0];
if (dtDeposit.Rows.Count > 0)
{
Model.Model_ErpMemberCardRechargeDeposit rechargeModel = bllDeposit.GetModel(dtDeposit.Rows[0]);
decimal PaytoCardValue = bllDepositRecord.GetHavePayRecordAmount(StrNumber, rechargeModel.Mcrd_RechargeNumber);
decimal DepositValue = bllDepositRecord.GetDepositRecordAmount(StrNumber, rechargeModel.Mcrd_RechargeNumber);
rechargeModel.Mcrd_BComplete = -1;
clist.Add(bllDeposit.GetUpdateCommandInfo(rechargeModel));
SaveBindMemeberCardData(MCrad, StrTime, StrUserName, PaytoCardValue, DepositValue, ref clist);
if (clist.Count > 0)
{
if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
{
MessageBoxCustom.Show("退款成功");
IsSaveed = true;
this.Close();
}
else
{ MessageBoxCustom.Show("退款失败"); }
}
}
else
{
MessageBoxCustom.Show("退款失败,无查询到有充值定金的记录!");
}
}
}
}
///
/// 保存退款金额记录
///
///
///
///
///
void SaveBindMemeberCardData(LYFZ.Model.Model_ErpMemberCard MCrad, DateTime StrTime, string StrUserName, decimal PaytoCardValue, decimal DepositValue,ref List clist)
{
decimal BeforeMoney = MCrad.Mc_Money;
MCrad.Mc_Money = MCrad.Mc_Money - PaytoCardValue;
MCrad.Mc_UpdateDateTime = StrTime;
MCrad.Mc_UpdateName = StrUserName;
clist.Add(mcbll.GetUpdateCommandInfo(MCrad));
decimal TouchAccount = 0;
LYFZ.Model.Model_ErpMemberCardAmountChangeLOG MCardLOG = new Model.Model_ErpMemberCardAmountChangeLOG();
MCardLOG.Mcacl_Type = "1";
MCardLOG.Mcacl_Number = this.StrNumber;
MCardLOG.Mcacl_OriginalAmount = BeforeMoney;
MCardLOG.Mcacl_ExistingAmount = BeforeMoney - (PaytoCardValue + TouchAccount);
MCardLOG.Mcacl_UseAmount = PaytoCardValue + TouchAccount;
MCardLOG.Mcacl_Remark = "主卡" + this.txtCradNumber.Text.Trim() + " 充值定金退款金额为:" + PaytoCardValue + "元";
MCardLOG.Mcacl_CreateDatetime = StrTime;
MCardLOG.Mcacl_CreateName = StrUserName;
clist.Add(mcplogbll.GetAddCommandInfo(MCardLOG));
if (PaytoCardValue>0)
{
LYFZ.Model.Model_ErpMemberCardTakeCash modelTakeCash = new Model.Model_ErpMemberCardTakeCash();
modelTakeCash.Mctkc_Number = this.StrNumber;
modelTakeCash.Mctkc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
modelTakeCash.Mctkc_TakeCashAmount = Convert.ToDecimal(txtCashAmount.Text.Trim());
modelTakeCash.Mctkc_AuditStatus = "未审核";
modelTakeCash.Mctkc_AuditName = "";
modelTakeCash.Mctkc_CreateDatetime = StrTime;
modelTakeCash.Mctkc_CreateName = StrUserName;
modelTakeCash.Mctkc_TakeCashType = "充值定金退款";
clist.Add(mctcbll.GetAddCommandInfo(modelTakeCash));
}
}
///
/// 取消
///
///
///
protected override void btnCancel_Click(object sender, EventArgs e)
{ this.Close(); }
///
/// 提现金额限制输入
///
///
///
protected override void txtCashAmount_KeyPress(object sender, KeyPressEventArgs e)
{
if (Convert.ToString(e.KeyChar) == ".")
{
if (this.txtCashAmount.Text.Trim().IndexOf('.') != -1)
{ e.Handled = true; }
}
else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
}
///
/// 摸帐金额限制输入
///
///
///
protected override void txtTouchAccount_KeyPress(object sender, KeyPressEventArgs e)
{
if (Convert.ToString(e.KeyChar) == ".")
{
if (this.txtTouchAccount.Text.Trim().IndexOf('.') != -1)
{ e.Handled = true; }
}
else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
}
}
}