123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm
- {
- public partial class ServiceKoufeiSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.ServiceKoufeiSuperSmallForm
- {
- public ServiceKoufeiSuperSmallForm()
- {
- }
- LYFZ.BLL.BLL_ErpSMSRecord rbll = new BLL.BLL_ErpSMSRecord();
- LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
- LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
- LYFZ.BLL.BLL_ErpMemberCardServiceContent mcscbll = new BLL.BLL_ErpMemberCardServiceContent();
- LYFZ.BLL.BLL_ErpMemberCardServiceContentUseLog mcsculog = new BLL.BLL_ErpMemberCardServiceContentUseLog();
- /// <summary>
- /// 要扣费的数据列表
- /// </summary>
- public ArrayList Servicelist = new ArrayList();
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 会员卡号
- /// </summary>
- private string StrMemberCardNumber = "";
- /// <summary>
- /// 会员编号
- /// </summary>
- private string StrNumber = "";
- /// <summary>
- /// 手机码
- /// </summary>
- private string StrTelephone = "";
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void ServiceKoufeiSuperSmallForm_Shown(object sender, EventArgs e)
- {
- for (int i = 0; i < Servicelist.Count; i++)
- {
- Hashtable htData = (Hashtable)Servicelist[i];
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = htData["ServiceNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = htData["ServiceName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "1";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = htData["ServiceID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- this.StrNumber = htData["MemberNumber"].ToString().Trim();
- this.StrMemberCardNumber = htData["MemberCardNumber"].ToString().Trim();
- this.StrTelephone = htData["strTelephone"].ToString().Trim();
- this.dgvData.Rows.Add(dgvr);
- }
- }
- /// <summary>
- /// 服务次数离开事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtCount_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (Convert.ToString(e.KeyChar) == "0")
- {
- if (this.txtCount.Text.Trim() == "")
- { e.Handled = true; }
- }
- else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { this.txtCount.Text = ""; e.Handled = true; }
- }
- /// <summary>
- /// 服务次数离开事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtCount_Leave(object sender, EventArgs e)
- {
- if (this.txtCount.Tag != null)
- {
- if (this.txtCount.Tag.ToString().Trim() == "A")
- {
- this.dgvData.CurrentRow.Cells["Column3"].Value = this.txtCount.Text.Trim();
- this.dgvData.CurrentRow.Tag = "1";
- }
- this.txtCount.Visible = false;
- }
- }
- private int Location_X = 0;
- private int Location_Y = 0;
- private int cellValue = 0;
- /// <summary>
- /// 数据列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgvData_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.RowIndex != -1 && e.ColumnIndex != -1)
- {
- if (this.dgvData.Columns[e.ColumnIndex].Name == "Column3")//
- {
- DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex];
- Rectangle rect = this.dgvData.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, true);
- this.txtCount.Location = new Point(rect.Location.X + this.Location_X, rect.Location.Y + this.Location_Y);
- this.txtCount.Size = rect.Size;
- this.txtCount.Visible = true;
- this.txtCount.Text = cell.Value.ToString().Trim();
- if (cell.Value.ToString().Trim() != "")
- { this.cellValue = Convert.ToInt32(cell.Value); }
- else { this.cellValue = 0; }
- this.txtCount.Tag = "A";
- this.txtCount.Focus();
- }
- else
- { this.txtCount.Visible = false; }
- }
- }
- /// <summary>
- /// 数据列表单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgvData_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- this.txtCount.Visible = false;
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnOK_Click(object sender, EventArgs e)
- {
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- LYFZ.Model.Model_ErpMemberCardServiceContent model = null;
- List<LYFZ.Model.Model_ErpMemberCardServiceContent> mlist = mcscbll.GetModelList("Mcse_Number = '" + this.StrNumber.Trim() + "'");
- DateTime strTime = SDateTime.Now;
- string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- string strMagess = "";
- List<Hashtable> hlist = new List<Hashtable>();
- Hashtable htData2 = null;
- for (int i = 0; i < this.dgvData.Rows.Count; i++)
- {
- for (int j = 0; j < mlist.Count; j++)
- {
- if (this.dgvData.Rows[i].Cells["Column4"].Value.ToString().Trim() == mlist[j].ID.ToString().Trim())
- {
- model = mlist[j];
- model.Mcse_ServiceCount = model.Mcse_ServiceCount - Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
- model.Mcse_UpdateDateTime = strTime;
- model.Mcse_UpdateName = strUserID;
- clist.Add(mcscbll.GetUpdateCommandInfo(model));
- LYFZ.Model.Model_ErpMemberCardServiceContentUseLog modelLog = new Model.Model_ErpMemberCardServiceContentUseLog();
- modelLog.Mcsl_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- modelLog.Mcsl_Number = this.StrNumber;
- modelLog.Mcsl_MemberServiceNumber = this.dgvData.Rows[i].Cells["Column1"].Value.ToString().Trim();
- modelLog.Mcsl_ServiceContent = this.dgvData.Rows[i].Cells["Column2"].Value.ToString().Trim();
- modelLog.Mcsl_ServiceUesNumber = Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
- modelLog.Mcsl_ServiceUesAfterNumber = model.Mcse_ServiceCount;
- modelLog.Mcsl_UpdateDateTime = strTime;
- modelLog.Mcsl_UpdateName = strUserID;
- clist.Add(mcsculog.GetAddCommandInfo(modelLog));
- strMagess += modelLog.Mcsl_ServiceContent + "(使用" + modelLog.Mcsl_ServiceUesNumber + "次,剩余可使用次数" + model.Mcse_ServiceCount + "次);";
- htData2 = new Hashtable();
- htData2["ItemName"] = modelLog.Mcsl_ServiceContent;
- htData2["UseCount"] = modelLog.Mcsl_ServiceUesNumber;
- htData2["UseAfterCount"] = modelLog.Mcsl_ServiceUesAfterNumber;
- htData2["UseTime"] = modelLog.Mcsl_UpdateDateTime.ToString("yyyy-MM-dd HH:mm"); ;
- htData2["JingShouRen"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- hlist.Add(htData2);
- break;
- }
- }
- }
- if (clist.Count > 0)
- {
- DataTable tbl = sgbll.GetSystemConfigureCustom("Sconfig_IsEnabled", "Sconfig_Code = 'SMSCashSpending'").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- if (Convert.ToBoolean(tbl.Rows[0]["Sconfig_IsEnabled"]))
- {
- Model.Model_ErpSMSRecord modelsms = new Model.Model_ErpSMSRecord();
- modelsms.Smsr_RecipientNumber = this.StrTelephone;
- modelsms.Smsr_Content = "您会员卡" + this.StrMemberCardNumber + "于日期" + strTime.ToString("MM-dd HH:mm") + "消费:" + strMagess + "。";
- modelsms.Smsr_SendCreateDatetime = strTime;
- modelsms.Smsr_Status = "暂未发送";
- modelsms.Smsr_SendPeople = strUserID;
- modelsms.Smsr_CreateDatetime = strTime;
- clist.Add(rbll.GetAddCommandInfo(modelsms));
- }
- }
- if (MessageBoxCustom.Show("确定要消费吗", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
- { MessageBoxCustom.Show("消费扣除次数失败"); return; }
- this.IsSaveed = true;
- LYFZ.Model.Model_ErpMemberCard modelMc = mcbll.GetModel("Mc_Number", this.StrNumber);
- LYFZ.BLL.OrderPayment_Member.MemberServiceCardUse(modelMc.Mc_CustomerNumber, modelMc.Mc_CradNumber, strMagess);
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.Print))
- {
- LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.RechargePrintMessageSuperSmallForm frmMesg = new RechargePrintMessageSuperSmallForm();
- frmMesg.lblNameTip = "扣费成功!";
- frmMesg.ShowDialog();
- if (frmMesg.IsSaveed)
- {
- Hashtable htDataX = new Hashtable();
- htDataX["hlist"] = hlist;
- htDataX["strNumber"] = this.StrNumber;
- LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.会员服务消费, htDataX);
- }
- }
- this.Close();
- }
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnCancel_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void ServiceKoufeiSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (!this.IsSaveed)
- {
- if (MessageBoxCustom.Show("确定要关闭吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { e.Cancel = true; }
- }
- }
- }
- }
|