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(); /// /// 会员卡编号 /// public string StrNumber; /// /// 会员卡号 /// public string CradNumber; /// /// 持卡人 /// public string CradName; /// /// 会员卡积分 /// public string CradPoints; /// /// 是否保存 /// public bool IsSaveed = false; /// /// 订单号 /// private string StrOrdNumber = ""; /// /// 本地分店ID /// string strInfoID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); /// /// 窗体加载事件 /// /// /// protected override void ReferralPointsSuperSmallForm_Load(object sender, EventArgs e) { this.txtCardName.Text = this.CradName; this.txtCardNumber.Text = this.CradNumber; this.txtPoints.Text = this.CradPoints; } /// /// 关闭窗体后发生事件 /// /// /// protected override void ReferralPointsSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e) { GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner; frm1.RefreshParentForm = IsSaveed; } /// /// 确定 /// /// /// 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 clist = new List(); #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("赠送失败"); } } } /// /// 取消 /// /// /// protected override void btnCancel_Click(object sender, EventArgs e) { this.Close(); } /// /// 列表事件双击 /// /// /// 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; } /// /// 回车 /// /// /// protected override void lstTextQuery_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.lstTextQuery_MouseDoubleClick(this, null); } } /// /// 列表失去焦点 /// /// /// protected override void panelEx2_Click(object sender, EventArgs e) { this.lstTextQuery.Visible = false; } /// /// 输入值变化 /// /// /// protected override void txtTextQuery_EventTextBoxEx_TextChanged(object sender, EventArgs e) { if (this.txtTextQuery.Text.Trim() == "") { this.lstTextQuery.Visible = true; } } /// /// 点击输入框 /// /// /// protected override void txtTextQuery_Click(object sender, EventArgs e) { this.txtTextQuery_EventTextBoxEx_TextChanged(null, null); } /// /// 按键盘上的下健时 /// /// /// 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); } } /// /// 查询获取订单信息 /// /// 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; } } } }