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.Web.UI.WebControls; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm { public partial class AddPhotographerConferenceSmallForm : LYFZ.Software.UI.MembershipManage.SetSmallForm.AddPhotographerConferenceSmallForm { LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard(); LYFZ.BLL.BLL_ErpMemberCardGradeSet mcgsbll = new BLL.BLL_ErpMemberCardGradeSet(); LYFZ.BLL.BLL_ErpMemberCardValidity mcvybll = new BLL.BLL_ErpMemberCardValidity(); LYFZ.BLL.BLL_ErpMemberCardPhotographerMain mcpmbll = new BLL.BLL_ErpMemberCardPhotographerMain(); LYFZ.BLL.BLL_ErpMemberCardPhotographerVice mcpvbll = new BLL.BLL_ErpMemberCardPhotographerVice(); LYFZ.BLL.BLL_ErpMemberCardPhotographerGiftSet mcpgsbll = new BLL.BLL_ErpMemberCardPhotographerGiftSet(); public AddPhotographerConferenceSmallForm() { this.btnUpdateValidity.Click += btnUpdateValidity_Click; this.chkValidity.CheckedChanged += chkValidity_CheckedChanged; } private DataTable tbl_Grade = new DataTable(); private DataTable tbl_Gift = new DataTable(); DataTable tblMain = new DataTable(); /// /// 会员卡编号 /// public string StrNumber = ""; /// /// 是否保存 /// public bool IsSaveed = false; /// /// 窗体加载事件 /// /// /// protected override void AddPhotographerConferenceSmallForm_Shown(object sender, EventArgs e) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OrdersReceivablesCompetence, LYFZ.CustomAttributes.OperatingAuthority.OrderPaymentMethodSet)) { this.btnSet.Enabled = false; } if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.Member_PhotographerOpenCard)) { this.btnSave.Enabled = false; } } /// /// 窗体加载事件 /// /// /// protected override void AddPhotographerConferenceSmallForm_Load(object sender, EventArgs e) { tblMain = mcbll.GetView_Custom("tb_ErpMemberCardPhotographerMain", StrWhere: "").Tables[0]; tbl_Grade = mcgsbll.GetList("ID != 1 and Mcgs_OpenCardAoumnt>0", "Mcgs_AmountStart ASC").Tables[0]; tbl_Grade.PrimaryKey = new DataColumn[] { tbl_Grade.Columns["Mcgs_Number"] }; for (int i = 0; i < tbl_Grade.Rows.Count; i++) { this.cmbMemberType.Items.Add(new ListItem(tbl_Grade.Rows[i]["Mcgs_GradeName"].ToString().Trim(), tbl_Grade.Rows[i]["Mcgs_Number"].ToString().Trim())); } tbl_Gift = mcpgsbll.GetList("", "ID ASC").Tables[0]; #region 加载有效期 bool IsValidity = false; DataTable dt = mcbll.GetView_Custom("tb_ErpMemberCardValidity", StrWhere: "Mcvy_Number = '" + this.StrNumber + "' And Mcvy_Type = " + ((int)LYFZ.EnumPublic.MemberFunctionAttribute.新摄会) + "", ShowColumnName: "ID,Mcvy_ValidityTime").Tables[0]; if (dt.Rows.Count > 0) { this.chkValidity.Tag = dt.Rows[0]["ID"].ToString().Trim(); if (!string.IsNullOrEmpty(LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[0]["Mcvy_ValidityTime"].ToString().Trim()))) { IsValidity = true; this.dtpValidity.DateValue = dt.Rows[0]["Mcvy_ValidityTime"].ToString().Trim(); this.chkValidity.Checked = false; } } if (!IsValidity) { this.dtpValidity.DateValue = ""; this.chkValidity.Checked = true; } #endregion LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbPaymentMethod, false); } /// /// 保存 /// /// /// protected override void btnSave_Click(object sender, EventArgs e) { if (this.dgvUpgradeData.Rows.Count <= 0) { MessageBoxCustom.Show("摄友详情无数据"); return; } if (this.cmbPaymentMethod.Text.Trim() == "") { MessageBoxCustom.Show("请选择收款方式"); return; } if (MessageBoxCustom.Show("您确定要办理" + this.cmbMemberType.Text.Trim() + "并且收款" + this.dgvUpgradeData.Rows[0].Cells["Column1"].Value.ToString().Trim() + "元人民币吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } List clist = new List(); DateTime strTime = SDateTime.Now; ListItem lItem = (ListItem)this.cmbMemberType.SelectedItem; string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; LYFZ.Model.Model_ErpMemberCardPhotographerMain modelm = new Model.Model_ErpMemberCardPhotographerMain(); modelm.Mcpm_MyNumber = "my" + LYFZ.Command.Command_Validate.DateTimeToString(SDateTime.Now, "yyyyMMddHHmmssfff"); modelm.Mcpm_Number = this.StrNumber; modelm.Mcpm_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); modelm.Mcpm_GradeNumber = lItem.Value.Trim(); modelm.Mcpm_GradeName = lItem.Text.Trim(); modelm.Mcpm_UpgradeAoumnt = Convert.ToDecimal(this.dgvUpgradeData.Rows[0].Cells["Column1"].Value); modelm.Mcpm_UpgradePoints = Convert.ToInt32(this.dgvUpgradeData.Rows[0].Cells["Column2"].Value); modelm.Mcpm_PaymentMethod = this.cmbPaymentMethod.Tag.ToString().Trim(); modelm.Mcpm_PaymentName = strUserID; modelm.Mcpm_BackAoumnt = Convert.ToDecimal(this.dgvUpgradeData.Rows[0].Cells["Column3"].Value); modelm.Mcpm_BackStatus = "0"; modelm.Mcpm_OKBackAoumnt = 0; modelm.Mcpm_JingShouRen = ""; modelm.Mcpm_UpgradeAoumntAudit = ""; modelm.Mcpm_UpgradeAoumntAuditName = ""; modelm.Mcpm_UpgradeAoumntAuditRemark = ""; modelm.Mcpm_OKBackAoumntAudit = ""; modelm.Mcpm_OKBackAoumntAuditName = ""; modelm.Mcpm_OKBackAoumntAuditRemark = ""; modelm.Mcpm_CreateDatetime = strTime; modelm.Mcpm_CreateName = strUserID; clist.Add(mcpmbll.GetAddCommandInfo(modelm)); LYFZ.Model.Model_ErpMemberCardPhotographerVice modelv = null; for (int i = 0; i < this.dgvGift.Rows.Count; i++) { modelv = new Model.Model_ErpMemberCardPhotographerVice(); modelv.Mcpv_MyNumber = modelm.Mcpm_MyNumber; modelv.Mcpv_Number = this.StrNumber; modelv.Mcpv_GradeNumber = lItem.Value.Trim(); modelv.Mcpv_GradeName = lItem.Text.Trim(); modelv.Mcpv_GiftNumber = this.dgvGift.Rows[i].Cells["G_3"].Value.ToString().Trim(); modelv.Mcpv_GiftName = this.dgvGift.Rows[i].Cells["G_1"].Value.ToString().Trim(); modelv.Mcpv_GiftClassCode = this.dgvGift.Rows[i].Cells["G_4"].Value.ToString().Trim(); modelv.Mcpv_GiftClassName = this.dgvGift.Rows[i].Cells["G_5"].Value.ToString().Trim(); modelv.Mcpv_GiftType = this.dgvGift.Rows[i].Cells["G_6"].Value.ToString().Trim(); modelv.Mcpv_UseStatus = "0"; modelv.Mcpv_JingShouRen = ""; modelv.Mcpv_CreateDatetime = strTime; modelv.Mcpv_CreateName = strUserID; clist.Add(mcpvbll.GetAddCommandInfo(modelv)); } string StrGradeName = LYFZ.BLL.OrderPayment_Member.GetMemberUpgradeData(this.StrNumber, PhotographerUpgradeAmount: modelm.Mcpm_UpgradeAoumnt); if (StrGradeName != "") { LYFZ.Model.Model_ErpMemberCard mc = mcbll.GetModel("Mc_Number", this.StrNumber); mc.Mc_CardType = this.cmbMemberType.Text.Trim(); mc.Mc_UpdateDateTime = strTime; mc.Mc_UpdateName = strUserID; clist.Add(mcbll.GetUpdateCommandInfo(mc)); } #region 会员有效期 LYFZ.Model.Model_ErpMemberCardValidity modelValidity = null; LYFZ.Model.Model_ErpMemberCard MCrad = mcbll.GetModel("Mc_Number", this.StrNumber); if (this.chkValidity.Tag == null) { modelValidity = new Model.Model_ErpMemberCardValidity(); modelValidity.Mcvy_Number = this.StrNumber; modelValidity.Mcvy_Type = (int)LYFZ.EnumPublic.MemberFunctionAttribute.新摄会; if (this.chkValidity.Checked) { modelValidity.Mcvy_ValidityTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); } else { modelValidity.Mcvy_ValidityTime = Convert.ToDateTime(this.dtpValidity.DateValue).AddDays(1).AddSeconds(-1); } modelValidity.Mcvy_CreateDatetime = strTime; modelValidity.Mcvy_CreateName = strUserID; clist.Add(mcvybll.GetAddCommandInfo(modelValidity)); string StrLogTime = ""; if (string.IsNullOrEmpty(LYFZ.Command.Command_Validate.DateTimeToString(modelValidity.Mcvy_ValidityTime))) { StrLogTime += "‘永久有效’"; } else { StrLogTime += "’" + LYFZ.Command.Command_Validate.DateTimeToString(modelValidity.Mcvy_ValidityTime, "yyyy-MM-dd HH:mm:ss") + "’"; } clist.Add(LYFZ.BLL.OrderPayment_Member.GetValidityLogs("[新摄会新增]", MCrad.Mc_CradNumber, modelValidity.Mcvy_Type, StrLogTime,strUserID)); } else { modelValidity = mcvybll.GetModel(Convert.ToInt32(this.chkValidity.Tag)); DateTime dtTime = modelValidity.Mcvy_ValidityTime; string StrLogTime = ""; if (string.IsNullOrEmpty(LYFZ.Command.Command_Validate.DateTimeToString(modelValidity.Mcvy_ValidityTime))) { StrLogTime += "‘永久有效’"; } else { StrLogTime += "’" + LYFZ.Command.Command_Validate.DateTimeToString(modelValidity.Mcvy_ValidityTime, "yyyy-MM-dd HH:mm:ss") + "’"; } if (this.chkValidity.Checked) { modelValidity.Mcvy_ValidityTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); } else { modelValidity.Mcvy_ValidityTime = Convert.ToDateTime(this.dtpValidity.DateValue).AddDays(1).AddSeconds(-1); } if (LYFZ.Command.Command_Validate.DateTimeToString(dtTime) != LYFZ.Command.Command_Validate.DateTimeToString(modelValidity.Mcvy_ValidityTime)) { modelValidity.Mcvy_UpdateDatetime = strTime; modelValidity.Mcvy_UpdateName = strUserID; clist.Add(mcvybll.GetUpdateCommandInfo(modelValidity)); if (string.IsNullOrEmpty(LYFZ.Command.Command_Validate.DateTimeToString(modelValidity.Mcvy_ValidityTime))) { StrLogTime += "修改为‘永久有效’"; } else { StrLogTime += "修改为‘" + LYFZ.Command.Command_Validate.DateTimeToString(modelValidity.Mcvy_ValidityTime, "yyyy-MM-dd HH:mm:ss") + "’"; } clist.Add(LYFZ.BLL.OrderPayment_Member.GetValidityLogs("[新摄会修改]", MCrad.Mc_CradNumber, modelValidity.Mcvy_Type, StrLogTime,strUserID)); } } #endregion if (clist.Count > 0) { if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0) { this.IsSaveed = true; if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.Print)) { LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.RechargePrintMessageSuperSmallForm frmMesg = new SuperSmallForm.RechargePrintMessageSuperSmallForm(); frmMesg.lblNameTip = "办理成功!"; frmMesg.ShowDialog(); if (frmMesg.IsSaveed) { Hashtable htData = new Hashtable(); htData["strNumber"] = this.StrNumber; htData["strMyNumber"] = modelm.Mcpm_MyNumber.Trim(); LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.新摄会收款, htData); } } this.Close(); } else { MessageBoxCustom.Show("办理失败!"); } } } /// /// 取消 /// /// /// protected override void btnCancel_Click(object sender, EventArgs e) { this.Close(); } /// /// 会员等级选择事件 /// /// /// protected override void cmbMemberType_SelectedIndexChanged(object sender, EventArgs e) { if (this.cmbMemberType.Items.Count > 0) { ListItem lItem = (ListItem)this.cmbMemberType.SelectedItem; DataRow dtRow = tbl_Grade.Rows.Find(lItem.Value); this.dgvUpgradeData.Rows.Clear(); this.dgvGift.Rows.Clear(); if (tblMain.Rows.Count > 0) { DataRow[] dtRow3 = tblMain.Select("Mcpm_Number = '" + this.StrNumber + "' and Mcpm_GradeNumber = '" + lItem.Value.Trim() + "'"); if (dtRow3.Length > 0) { this.cmbMemberType.Text = ""; MessageBoxCustom.Show("您已办有此新摄会类型,不能重复办理"); return; } } DataGridViewRow dgvr = new DataGridViewRow(); DataGridViewCell cell = null; cell = new DataGridViewTextBoxCell(); cell.Value = dtRow["Mcgs_OpenCardAoumnt"].ToString().Trim(); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dtRow["Mcgs_ReturnNeededPoints"].ToString().Trim(); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dtRow["Mcgs_ReturnAoumnt"].ToString().Trim(); dgvr.Cells.Add(cell); this.dgvUpgradeData.Rows.Add(dgvr); DataRow[] dtRow2 = tbl_Gift.Select("Mcpgs_GradeNumber = '" + lItem.Value + "'"); for (int i = 0; i < dtRow2.Length; i++) { DataGridViewRow dgvr2 = new DataGridViewRow(); DataGridViewCell cell2 = null; cell2 = new DataGridViewTextBoxCell(); cell2.Value = dtRow2[i]["Mcpgs_GiftName"].ToString().Trim(); dgvr2.Cells.Add(cell2); cell2 = new DataGridViewTextBoxCell(); cell2.Value = "未使用"; dgvr2.Cells.Add(cell2); cell2 = new DataGridViewTextBoxCell(); cell2.Value = dtRow2[i]["Mcpgs_GiftNumber"].ToString().Trim(); dgvr2.Cells.Add(cell2); cell2 = new DataGridViewTextBoxCell(); cell2.Value = dtRow2[i]["Mcpgs_GiftClassCode"].ToString().Trim(); dgvr2.Cells.Add(cell2); cell2 = new DataGridViewTextBoxCell(); cell2.Value = dtRow2[i]["Mcpgs_GiftClassName"].ToString().Trim(); dgvr2.Cells.Add(cell2); cell2 = new DataGridViewTextBoxCell(); cell2.Value = dtRow2[i]["Mcpgs_GiftType"].ToString().Trim(); dgvr2.Cells.Add(cell2); this.dgvGift.Rows.Add(dgvr2); } } } /// /// 窗体关闭时发生 /// /// /// protected override void AddPhotographerConferenceSmallForm_FormClosed(object sender, FormClosedEventArgs e) { GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner; if (frm1 != null) { frm1.RefreshParentForm = IsSaveed; } } /// /// 设置 /// /// /// protected override void btnSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet(); frm.TypeName = "BEBACCAFCCEAGAIHH"; frm.Version = "Version"; if (frm.ShowDialog() == DialogResult.OK) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbPaymentMethod); } } /// /// 修改有效期 /// /// /// void btnUpdateValidity_Click(object sender, EventArgs e) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, CustomAttributes.OperatingAuthority.ValidityDateTime)) { LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm("MemberManage", CustomAttributes.OperatingAuthority.ValidityDateTime); if (frm.ShowDialog() == DialogResult.No) { return; } if (!LYFZ.BLL.BLL_ErpUser.GetRights(frm.CurrentAuthorizeUserRights.MemberManage, CustomAttributes.OperatingAuthority.ValidityDateTime, frm.User_BelongRoles)) { frm.SetAuthorizationResult(String.Format("授权失败,授权人没有'会员管理{0}'权限", LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm.ConvertEnumToDescription(CustomAttributes.OperatingAuthority.ValidityDateTime).ToString())); return; } else { frm.SetAuthorizationResult(); } } if (this.chkValidity.Checked) { this.chkValidity.Enabled = true; this.dtpValidity.Enabled = false; } else { this.chkValidity.Enabled = true; this.dtpValidity.Enabled = true; } } string StrValidityTime = ""; /// /// 永久选择事件 /// /// /// void chkValidity_CheckedChanged(object sender, EventArgs e) { if (this.chkValidity.Checked) { this.StrValidityTime = this.dtpValidity.DateValue; this.dtpValidity.DateValue = ""; this.dtpValidity.Enabled = false; } else { this.dtpValidity.Enabled = true; this.dtpValidity.DateValue = this.StrValidityTime; } } } }