123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- using LYFZ.Helper;
- using LYFZ.Software.MainBusiness.DoorCityProcess;
- using LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm;
- 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;
- namespace LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm
- {
- public partial class ReferralPointsSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.ReferralPointsSuperSmallForm
- {
- public ReferralPointsSuperSmallForm()
- {
- }
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
- LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
- LYFZ.BLL.BLL_ErpCustomerGroup cgbll = new BLL.BLL_ErpCustomerGroup();
- LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
- LYFZ.BLL.BLL_ErpMemberCardPoints mcpbll = new BLL.BLL_ErpMemberCardPoints();
- LYFZ.BLL.BLL_ErpMemberCardViceCard mcvcbll = new BLL.BLL_ErpMemberCardViceCard();
- LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcplogbll = new BLL.BLL_ErpMemberCardPointsLOG();
- /// <summary>
- /// 会员卡编号
- /// </summary>
- public string StrNumber;
- /// <summary>
- /// 会员卡号
- /// </summary>
- public string CradNumber;
- /// <summary>
- /// 持卡人
- /// </summary>
- public string CradName;
- /// <summary>
- /// 会员卡积分
- /// </summary>
- public string CradPoints;
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 订单号
- /// </summary>
- private string StrOrdNumber = "";
- /// <summary>
- /// 本地分店ID
- /// </summary>
- string strInfoID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void ReferralPointsSuperSmallForm_Load(object sender, EventArgs e)
- {
- this.txtCardName.Text = this.CradName;
- this.txtCardNumber.Text = this.CradNumber;
- this.txtPoints.Text = this.CradPoints;
- }
- /// <summary>
- /// 关闭窗体后发生事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void ReferralPointsSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner;
- frm1.RefreshParentForm = IsSaveed;
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnOK_Click(object sender, EventArgs e)
- {
- if (this.StrOrdNumber.Trim() == "")
- { MessageBoxCustom.Show("请选择订单"); return; }
- DateTime StrTime = SDateTime.Now;
- string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- List<CommandInfo> clist = new List<CommandInfo>();
- #region 将持卡人编号填到订单客户组的转介绍ID列去
- LYFZ.Model.Model_ErpCustomerGroup modelClientGroup = cgbll.GetModel("GP_OrderNumber", this.StrOrdNumber.Trim());
- if (modelClientGroup.GP_IntroducerCustomerID.Trim() != "")
- { MessageBoxCustom.Show("此订单号已经赠送过,不能再赠送!"); return; }
- modelClientGroup.GP_IntroducerCustomerID = "";
- DataTable tbl = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_Number = '" + this.StrNumber + "'", ShowColumnName: "Mc_CustomerNumber").Tables[0];
- if (tbl.Rows.Count > 0)
- { modelClientGroup.GP_IntroducerCustomerID = tbl.Rows[0]["Mc_CustomerNumber"].ToString().Trim(); }
- modelClientGroup.GP_UpdateDatetime = StrTime;
- modelClientGroup.GP_UpdateName = StrUserName;
- clist.Add(cgbll.GetUpdateCommandInfo(modelClientGroup));
- #endregion
- #region 主卡积分与积分记录
- int IntPointsIntr = Convert.ToInt32(this.txtGetPoints.Text.Trim());
- LYFZ.Model.Model_ErpMemberCardPoints model = mcpbll.GetModel("Mcps_Number", this.StrNumber);
- LYFZ.Model.Model_ErpMemberCardPointsLOG modelog = new Model.Model_ErpMemberCardPointsLOG();
- modelog.MPlg_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
- modelog.MPlg_Number = this.StrNumber;
- modelog.MPlg_Type = "3";
- modelog.MPlg_OriginalPoints = model.Mcps_AvailablePoints;
- model.Mcps_AvailablePoints = model.Mcps_AvailablePoints + IntPointsIntr;
- model.Mcps_TotalPoints = model.Mcps_TotalPoints + IntPointsIntr;
- model.Mcps_UpdateDateTime = StrTime;
- model.Mcps_UpdateName = StrUserName;
- modelog.MPlg_ExistingPoints = model.Mcps_AvailablePoints;
- modelog.MPlg_UsePoints = Convert.ToInt32(this.txtGetPoints.Text.Trim());
- modelog.MPlg_OrderNumber = this.StrOrdNumber;
- modelog.MPlg_ViceCardNumber = "";
- modelog.MPlg_Remark = "介绍" + this.lblName1.Text.Trim() + this.txtManName.Text.Trim() + "," + this.lblName2.Text.Trim() + this.txtWomanName.Text.Trim() + "," + this.lblOrderNumber.Text.Trim() + this.txtOrderNumber.Text.Trim() + ",消费" + this.lblPackagesPrice.Text.Trim() + this.txtSeriesPrice.Text.Trim() + ",本次共获取转介绍积分:" + this.txtGetPoints.Text.Trim();
- modelog.MPlg_CreateDatetime = StrTime;
- modelog.MPlg_CreateName = StrUserName;
- clist.Add(mcplogbll.GetAddCommandInfo(modelog));
- if (model.ID <= 0)
- {
- model.Mcps_Number = this.StrNumber;
- clist.Add(mcpbll.GetAddCommandInfo(model));
- }
- else
- { clist.Add(mcpbll.GetUpdateCommandInfo(model)); }
- #endregion
- if (clist.Count > 0)
- {
- if (MessageBoxCustom.Show("您确定要赠送吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- IsSaveed = true;
- LYFZ.Model.Model_ErpMemberCard modelCard = mcbll.GetModel("Mc_Number", this.StrNumber);
- DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerGroupID = '" + modelClientGroup.GP_CustomerGroupID + "' and GM_Master = '1'", ShowColumnName: "GM_CustomerID").Tables[0];
- //积分到达后发短信、介绍获得积分
- string StrContentText = "您介绍朋友订单" + this.StrOrdNumber + ",您获得转介绍积分(" + IntPointsIntr + ")分,当前可用积分(" + model.Mcps_AvailablePoints + ")分。";
- // LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS("", modelCard.Mc_CradNumber, modelCard.Mc_CustomerNumber, AvailablePoints: model.Mcps_AvailablePoints, GetReferralPoints: IntPointsIntr, StrContentText: StrContentText);
- //2017-03-24 刘工修改
- if (tblClient != null && tblClient.Rows.Count>0)
- LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS(tblClient.Rows[0]["GM_CustomerID"].ToString(), modelCard.Mc_CradNumber, modelCard.Mc_CustomerNumber, AvailablePoints: model.Mcps_AvailablePoints, GetReferralPoints: IntPointsIntr, StrContentText: StrContentText);
-
- MessageBoxCustom.Show("赠送成功");
- this.Close();
- }
- else { MessageBoxCustom.Show("赠送失败"); }
- }
- }
- /// <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 lstTextQuery_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (this.lstTextQuery.Items.Count > 0)
- {
- if (((ListItem)this.lstTextQuery.SelectedItem) != null)
- {
- this.GetOrdNumberGetData(((ListItem)this.lstTextQuery.SelectedItem).StrValue.ToString().Trim());
- this.txtTextQuery.Text = ((ListItem)this.lstTextQuery.SelectedItem).StrText;
- }
- }
- this.lstTextQuery.Visible = false;
- }
- /// <summary>
- /// 回车
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void lstTextQuery_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.lstTextQuery_MouseDoubleClick(this, null); }
- }
- /// <summary>
- /// 列表失去焦点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void panelEx2_Click(object sender, EventArgs e)
- { this.lstTextQuery.Visible = false; }
- /// <summary>
- /// 输入值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtTextQuery_EventTextBoxEx_TextChanged(object sender, EventArgs e)
- {
- if (this.txtTextQuery.Text.Trim() == "")
- { this.lstTextQuery.Visible = true; }
- }
- /// <summary>
- /// 点击输入框
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtTextQuery_Click(object sender, EventArgs e)
- { this.txtTextQuery_EventTextBoxEx_TextChanged(null, null); }
- /// <summary>
- /// 按键盘上的下健时
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtTextQuery_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
- { this.lstTextQuery.SelectedIndex = 0; this.lstTextQuery.Focus(); }
- else if (e.KeyCode == Keys.Enter)
- { LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.InputQueryClient(this.txtTextQuery, this.lstTextQuery); }
- }
- /// <summary>
- /// 查询获取订单信息
- /// </summary>
- /// <param name="StrNumber"></param>
- void GetOrdNumberGetData(string OrdNumber)
- {
- string strViewName = "tb_ErpOrder Left Join dbo.tb_ErpOrderDigital ON Ord_Number = Ordv_Number left join dbo.tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber";
- string strColumnName = "Ord_SeriesPrice,Cus_Name,Cus_Sex_cs,CASE [Ord_SinceOrderNumber] WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS ShowOrdNumber,Ord_SeriesName,Ord_Type,(select stuff((select ',' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as OrdPe_OrdersPerson,Ordv_ViceNumber,Case when Ord_Type = '1' then (select top 1 Ordpg_Sights from dbo.tb_ErpOrdersPhotography where Ordpg_Number = Ordv_Number and Ordpg_ViceNumber = Ordv_ViceNumber) else '' end AS Ordpg_Sights";
- DataTable tbl = orbll.GetView_Custom(strViewName, StrWhere: "Ordv_Number = '" + OrdNumber + "'", filedOrder: "Ordv_DigitalNumber ASC", ShowColumnName: strColumnName).Tables[0];
- if (tbl.Rows.Count > 0)
- {
- this.txtOrderNumber.Text = tbl.Rows[0]["ShowOrdNumber"].ToString().Trim();
- this.txtSeriesName.Text = tbl.Rows[0]["Ord_SeriesName"].ToString().Trim();
- this.txtOrdersPerson.Text = tbl.Rows[0]["OrdPe_OrdersPerson"].ToString().Trim();
- this.txtSeriesPrice.Text = tbl.Rows[0]["Ord_SeriesPrice"].ToString().Trim();
- if (Convert.ToDecimal(tbl.Rows[0]["Ord_SeriesPrice"]) > 0)
- {
- DataTable dt = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_Number = '" + this.StrNumber + "'", ShowColumnName: "Mc_CustomerNumber").Tables[0];
- this.txtGetPoints.Text = LYFZ.BLL.BLL_ErpMemberCard.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.txtReferral_RMB, Convert.ToDecimal(tbl.Rows[0]["Ord_SeriesPrice"]), strInfoID, dt.Rows[0]["Mc_CustomerNumber"].ToString().Trim()).ToString();
- }
- else
- { this.txtGetPoints.Text = "0"; }
- string[] StrNameArray = tbl.Rows[0]["Cus_Name"].ToString().Trim().Split('/');
- string[] StrSexArray = tbl.Rows[0]["Cus_Sex_cs"].ToString().Trim().Split('/');
- if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "0")
- {
- if (StrNameArray.Length > 1)
- {
- if (StrSexArray[0].Trim() == "男")
- { this.lblName1.Text = "男宾姓名:"; }
- else if (StrSexArray[0].Trim() == "女")
- { this.lblName2.Text = "女宾姓名:"; }
- this.txtManName.Text = StrNameArray[0].Trim();
- if (StrSexArray[1].Trim() == "男")
- { this.lblName1.Text = "男宾姓名:"; }
- else if (StrSexArray[1].Trim() == "女")
- { this.lblName2.Text = "女宾姓名:"; }
- this.txtWomanName.Text = StrNameArray[1].Trim();
- }
- else
- {
- this.lblName1.Text = "男宾姓名:";
- this.lblName2.Text = "女宾姓名:";
- if (StrSexArray[0].Trim() == "男")
- { this.txtManName.Text = StrNameArray[0].Trim(); }
- else if (StrSexArray[0].Trim() == "女")
- { this.txtWomanName.Text = StrNameArray[0].Trim(); }
- }
- this.lblName1.Location = new Point(26, lblName1.Location.Y);
- this.lblName2.Location = new Point(229, lblName2.Location.Y);
- }
- else if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "1")
- {
- this.lblName1.Text = "宝贝姓名:";
- this.lblName2.Text = "家长姓名:";
- this.txtManName.Text = StrNameArray[0].Trim();
- this.txtWomanName.Text = StrNameArray[1].Trim();
- this.lblName1.Location = new Point(26, lblName1.Location.Y);
- this.lblName2.Location = new Point(229, lblName2.Location.Y);
- }
- else if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "2" || tbl.Rows[0]["Ord_Type"].ToString().Trim() == "3")
- {
- this.lblName1.Text = "客户姓名:";
- this.lblName2.Text = "客户性别:";
- this.txtManName.Text = StrNameArray[0].Trim();
- this.txtWomanName.Text = StrSexArray[0].Trim();
- this.lblName1.Location = new Point(26, lblName1.Location.Y);
- this.lblName2.Location = new Point(229, lblName2.Location.Y);
- }
- DataTable tblCLientGroup = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_OrderNumber = '" + OrdNumber + "'", ShowColumnName: "GP_IntroducerCustomerID").Tables[0];
- this.btnOK.Enabled = true;
- if (tblCLientGroup.Rows.Count > 0)
- {
- if (tblCLientGroup.Rows[0]["GP_IntroducerCustomerID"].ToString().Trim() != "")
- { this.btnOK.Enabled = false; MessageBoxCustom.Show("此订单号已经赠送过,不能再赠送!"); return; }
- }
- this.StrOrdNumber = OrdNumber;
- }
- }
- }
- }
|