private void LoadRecord() { lblHeader.Text = mstCaption + " for customer : " + mContactDetails.ContactName; txtDOB.Text = DateTime.Now.AddYears(-18).ToString("yyyy-MM-dd"); txtRewardCardNo.Text = mContactDetails.ContactCode.Length > 15 ? mContactDetails.ContactCode.Substring(0, 15) : mContactDetails.ContactCode; txtRewardCardExpiryDate.Text = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd"); Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(mContactDetails.ContactID); if (clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardNo.Text = clsContactRewardDetails.RewardCardNo; txtDOB.Text = clsContactRewardDetails.BirthDate.ToString("yyyy-MM-dd"); txtRewardCardExpiryDate.Text = clsContactRewardDetails.ExpiryDate.ToString("yyyy-MM-dd"); } if (TerminalDetails.AutoGenerateRewardCardNo) { if ((mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID == Constants.ZERO) || mRewardCardStatus == RewardCardStatus.Replaced_Lost) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactReward.Connection, clsContactReward.Transaction); BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.RewardCard_Country_Code, BarcodeHelper.RewardCard_ManufacturerCode, clsERPConfig.get_LastRewardCardNo()); txtRewardCardNo.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit; } } else { txtRewardCardNo.Enabled = true; } clsContactReward.CommitAndDispose(); if (mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardExpiryDate.Enabled = false; this.Refresh(); txtRewardCardNo.Focus(); MessageBox.Show("Reward Card No: " + clsContactRewardDetails.RewardCardNo + " was already issued last " + clsContactRewardDetails.RewardAwardDate.ToString("MMM dd, yyyy") + " to " + mContactDetails.ContactName + "." + Environment.NewLine + "Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { txtRewardCardExpiryDate.Enabled = false; txtDOB.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Reactivated_Lost) { txtRewardCardNo.Enabled = true; txtRewardCardExpiryDate.Enabled = true; txtRewardCardNo.Focus(); } else if (mRewardCardStatus == RewardCardStatus.ReNew) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } }
private bool SaveRecord() { long lngCustomerID = long.Parse(cboCustomer.SelectedItem.Value); decimal decCurrentRewardPoints = (txtCurrentRewardPoints.Text.Trim() == string.Empty) ? 0 : Decimal.Parse(txtCurrentRewardPoints.Text); decimal decRedeemRewardPoints = (txtRedeemRewardPoints.Text.Trim() == string.Empty) ? 0 : Decimal.Parse(txtRedeemRewardPoints.Text); decimal decNewRewardPoints = decCurrentRewardPoints - decRedeemRewardPoints; if (lngCustomerID != 0) { string javaScript; // decRedeemRewardPoints < 0 || <-- allow this negative for adjustment if (decRedeemRewardPoints > decCurrentRewardPoints || txtRedeemRewardPoints.Enabled == false) { // Cannot be negative or less than current reward points or expired javaScript = "window.alert('Sorry the reward points you are claiming is higher than the current points. Please enter again.')"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updSave, this.updSave.GetType(), "openwindow", javaScript, true); return(false); } RetailPlus.Security.AccessUserDetails clsAccessUserDetails = (RetailPlus.Security.AccessUserDetails)Session["AccessUserDetails"]; // this should comes before earning of points otherwise this will be wrong. Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(lngCustomerID); string strReason = "Redeemed " + decRedeemRewardPoints + " using Reward Card #: " + clsContactRewardDetails.RewardCardNo; strReason += (txtRemarks.Text.Trim() == string.Empty) ? "" : " Remarks:" + txtRemarks.Text; clsContactReward.AddMovement(lngCustomerID, DateTime.Now, decCurrentRewardPoints, -decRedeemRewardPoints, decCurrentRewardPoints - decRedeemRewardPoints, clsContactRewardDetails.ExpiryDate, strReason, "BACKEND", clsAccessUserDetails.Name, DateTime.Now.ToString("yyyyMMddHHmmss").Trim()); clsContactReward.DeductPoints(lngCustomerID, decRedeemRewardPoints); clsContactReward.CommitAndDispose(); //PrintRewardsRedemptionSlip(); javaScript = "window.alert('Reward points has been updated.')"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updSave, this.updSave.GetType(), "openwindow", javaScript, true); txtCurrentRewardPoints.Text = decNewRewardPoints.ToString(); txtRedeemRewardPoints.Text = "0"; txtNewRewardPoints.Text = decNewRewardPoints.ToString(); txtRemarks.Text = string.Empty; return(true); } return(false); }
protected void cboCustomer_SelectedIndexChanged(object sender, System.EventArgs e) { try { if (cboCustomer.SelectedItem.Value != Constants.ZERO_STRING) { long lngCustomerID = long.Parse(cboCustomer.SelectedItem.Value); Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(lngCustomerID); clsContactReward.CommitAndDispose(); txtRewardCardNo.Text = clsContactRewardDetails.RewardCardNo; txtCurrentRewardPoints.Text = clsContactRewardDetails.RewardPoints.ToString(); //txtRedeemRewardPoints.Enabled = (DateTime.Now > clsContactRewardDetails.ExpiryDate) ? true : false; txtRedeemRewardPoints.Text = (DateTime.Now > clsContactRewardDetails.ExpiryDate) ? "0" : txtRedeemRewardPoints.Text; txtNewRewardPoints.Text = Convert.ToInt32(Convert.ToDecimal(txtCurrentRewardPoints.Text) - Convert.ToDecimal(txtRedeemRewardPoints.Text)).ToString(); } } catch (Exception ex) { throw ex; } }
private bool SaveRecord() { long lngCustomerID = long.Parse(cboCustomer.SelectedItem.Value); decimal decCurrentRewardPoints = (txtCurrentRewardPoints.Text.Trim() == string.Empty) ? 0 : Decimal.Parse(txtCurrentRewardPoints.Text); decimal decRedeemRewardPoints = (txtRedeemRewardPoints.Text.Trim() == string.Empty) ? 0 : Decimal.Parse(txtRedeemRewardPoints.Text); decimal decNewRewardPoints = decCurrentRewardPoints - decRedeemRewardPoints; if (lngCustomerID != 0) { string javaScript; // decRedeemRewardPoints < 0 || <-- allow this negative for adjustment if (decRedeemRewardPoints > decCurrentRewardPoints || txtRedeemRewardPoints.Enabled==false) { // Cannot be negative or less than current reward points or expired javaScript = "window.alert('Sorry the reward points you are claiming is higher than the current points. Please enter again.')"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updSave, this.updSave.GetType(), "openwindow", javaScript, true); return false; } RetailPlus.Security.AccessUserDetails clsAccessUserDetails = (RetailPlus.Security.AccessUserDetails) Session["AccessUserDetails"]; // this should comes before earning of points otherwise this will be wrong. Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(lngCustomerID); string strReason = "Redeemed " + decRedeemRewardPoints + " using Reward Card #: " + clsContactRewardDetails.RewardCardNo; strReason += (txtRemarks.Text.Trim() == string.Empty) ? "" : " Remarks:" + txtRemarks.Text; clsContactReward.AddMovement(lngCustomerID, DateTime.Now, decCurrentRewardPoints, -decRedeemRewardPoints, decCurrentRewardPoints - decRedeemRewardPoints, clsContactRewardDetails.ExpiryDate, strReason, "BACKEND", clsAccessUserDetails.Name, DateTime.Now.ToString("yyyyMMddHHmmss").Trim()); clsContactReward.DeductPoints(lngCustomerID, decRedeemRewardPoints); clsContactReward.CommitAndDispose(); //PrintRewardsRedemptionSlip(); javaScript = "window.alert('Reward points has been updated.')"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updSave, this.updSave.GetType(), "openwindow", javaScript, true); txtCurrentRewardPoints.Text = decNewRewardPoints.ToString(); txtRedeemRewardPoints.Text = "0"; txtNewRewardPoints.Text = decNewRewardPoints.ToString(); txtRemarks.Text = string.Empty; return true; } return false; }
private bool SaveRecord() { bool boRetValue = false; if (txtRewardCardNo.Text.Trim() == string.Empty) { MessageBox.Show("Sorry please enter a valid reward card no.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } DateTime dteExpiryDate = DateTime.MinValue; try { dteExpiryDate = DateTime.Parse(txtRewardCardExpiryDate.Text); } catch { MessageBox.Show("Please enter a valid expiry date in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } DateTime dteBirthDate = DateTime.MinValue; try { dteBirthDate = DateTime.Parse(txtDOB.Text); } catch { MessageBox.Show("Please enter a valid date of birth in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } if (mRewardCardStatus == RewardCardStatus.New) { if (MessageBox.Show("Are you sure you want to issue card no: " + txtRewardCardNo.Text + " to " + mContactDetails.ContactName + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { if (MessageBox.Show("Are you sure you want to declare card no: " + txtRewardCardNo.Text + " as " + mRewardCardStatus.ToString("G") + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired) { if (MessageBox.Show("Are you sure you want to replace existing reward card w/ new card no: " + txtRewardCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mRewardCardStatus == RewardCardStatus.Reactivated_Lost) { if (MessageBox.Show("Are you sure you want to reactivate reward card no: " + txtRewardCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } } else if (mRewardCardStatus == RewardCardStatus.ReNew) { if (MessageBox.Show("Are you sure you want to renew card no: " + txtRewardCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(boRetValue); } if (dteExpiryDate < DateTime.Now) { MessageBox.Show("Expiry date must not be less than date today. Please enter a valid expiry date. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(boRetValue); } } Data.ContactRewardDetails clsDetails = new Data.ContactRewardDetails(); clsDetails.ContactID = mContactDetails.ContactID; clsDetails.RewardCardNo = txtRewardCardNo.Text; clsDetails.RewardPoints = 0; clsDetails.RewardAwardDate = DateTime.Now; clsDetails.ExpiryDate = dteExpiryDate; clsDetails.BirthDate = dteBirthDate; Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(txtRewardCardNo.Text); if (clsContactRewardDetails.ContactID != Constants.ZERO) { if (mRewardCardStatus == RewardCardStatus.New || (mRewardCardStatus != RewardCardStatus.New && clsContactRewardDetails.ContactID != mContactDetails.ContactID)) { clsContactReward.CommitAndDispose(); MessageBox.Show("Reward Card No: " + clsContactRewardDetails.RewardCardNo + " was already issued on " + clsContactRewardDetails.RewardAwardDate.ToString("MMM dd, yyyy") + " to another customer." + Environment.NewLine + "Please enter another Reward Card No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtRewardCardNo.Focus(); txtRewardCardNo.SelectAll(); return(boRetValue); } } if (mRewardCardStatus == RewardCardStatus.New) { clsDetails.RewardActive = true; } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { clsDetails.RewardActive = false; } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired || mRewardCardStatus == RewardCardStatus.Reactivated_Lost || mRewardCardStatus == RewardCardStatus.ReNew) { clsDetails.RewardActive = true; } clsDetails.RewardCardStatus = mRewardCardStatus; boRetValue = clsContactReward.Update(clsDetails); mContactDetails.RewardDetails = clsDetails; clsContactReward.CommitAndDispose(); boRetValue = true; return(boRetValue); }
private void LoadRecord() { lblHeader.Text = mstCaption + " for customer : " + mContactDetails.ContactName; txtDOB.Text = DateTime.Now.AddYears(-18).ToString("yyyy-MM-dd"); txtRewardCardNo.Text = mContactDetails.ContactCode; txtRewardCardExpiryDate.Text = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd"); Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(mContactDetails.ContactID); if (clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardNo.Text = clsContactRewardDetails.RewardCardNo; txtDOB.Text = clsContactRewardDetails.BirthDate.ToString("yyyy-MM-dd"); txtRewardCardExpiryDate.Text = clsContactRewardDetails.ExpiryDate.ToString("yyyy-MM-dd"); } if (mTerminalDetails.AutoGenerateRewardCardNo == true) { if ((mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID == Constants.ZERO) || mRewardCardStatus == RewardCardStatus.Replaced_Lost) { Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactReward.Connection, clsContactReward.Transaction); txtRewardCardNo.Text = clsERPConfig.get_LastRewardCardNo(); } } else { txtRewardCardNo.Enabled = true; } clsContactReward.CommitAndDispose(); if (mRewardCardStatus == RewardCardStatus.New && clsContactRewardDetails.ContactID != Constants.ZERO) { txtRewardCardExpiryDate.Enabled = false; this.Refresh(); txtRewardCardNo.Focus(); MessageBox.Show("Reward Card No: " + clsContactRewardDetails.RewardCardNo + " was already issued last " + clsContactRewardDetails.RewardAwardDate.ToString("MMM dd, yyyy") + " to " + mContactDetails.ContactName + "." + Environment.NewLine + "Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { txtRewardCardExpiryDate.Enabled = false; txtDOB.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } else if (mRewardCardStatus == RewardCardStatus.Reactivated_Lost) { txtRewardCardNo.Enabled = true; txtRewardCardExpiryDate.Enabled = true; txtRewardCardNo.Focus(); } else if (mRewardCardStatus == RewardCardStatus.ReNew) { txtRewardCardExpiryDate.Enabled = true; txtRewardCardExpiryDate.Focus(); } }
private bool SaveRecord() { bool boRetValue = false; if (txtRewardCardNo.Text.Trim() == string.Empty) { MessageBox.Show("Sorry please enter a valid reward card no.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } DateTime dteExpiryDate = DateTime.MinValue; try { dteExpiryDate = DateTime.Parse(txtRewardCardExpiryDate.Text); } catch { MessageBox.Show("Please enter a valid expiry date in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } DateTime dteBirthDate = DateTime.MinValue; try { dteBirthDate = DateTime.Parse(txtDOB.Text); } catch { MessageBox.Show("Please enter a valid date of birth in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } if (mRewardCardStatus == RewardCardStatus.New) { if (MessageBox.Show("Are you sure you want to issue card no: " + txtRewardCardNo.Text + " to " + mContactDetails.ContactName + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { if (MessageBox.Show("Are you sure you want to declare card no: " + txtRewardCardNo.Text + " as " + mRewardCardStatus.ToString("G") + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired) { if (MessageBox.Show("Are you sure you want to replace existing reward card w/ new card no: " + txtRewardCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mRewardCardStatus == RewardCardStatus.Reactivated_Lost) { if (MessageBox.Show("Are you sure you want to reactivate reward card no: " + txtRewardCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } } else if (mRewardCardStatus == RewardCardStatus.ReNew) { if (MessageBox.Show("Are you sure you want to renew card no: " + txtRewardCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return boRetValue; } if (dteExpiryDate < DateTime.Now) { MessageBox.Show("Expiry date must not be less than date today. Please enter a valid expiry date. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); return boRetValue; } } Data.ContactRewardDetails clsDetails = new Data.ContactRewardDetails(); clsDetails.ContactID = mContactDetails.ContactID; clsDetails.RewardCardNo = txtRewardCardNo.Text; clsDetails.RewardPoints = 0; clsDetails.RewardAwardDate = DateTime.Now; clsDetails.ExpiryDate = dteExpiryDate; clsDetails.BirthDate = dteBirthDate; Data.ContactReward clsContactReward = new Data.ContactReward(); Data.ContactRewardDetails clsContactRewardDetails = clsContactReward.Details(txtRewardCardNo.Text); if (clsContactRewardDetails.ContactID != Constants.ZERO) { if (mRewardCardStatus == RewardCardStatus.New || (mRewardCardStatus != RewardCardStatus.New && clsContactRewardDetails.ContactID != mContactDetails.ContactID)) { clsContactReward.CommitAndDispose(); MessageBox.Show("Reward Card No: " + clsContactRewardDetails.RewardCardNo + " was already issued on " + clsContactRewardDetails.RewardAwardDate.ToString("MMM dd, yyyy") + " to another customer." + Environment.NewLine + "Please enter another Reward Card No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtRewardCardNo.Focus(); txtRewardCardNo.SelectAll(); return boRetValue; } } if (mRewardCardStatus == RewardCardStatus.New) { clsDetails.RewardActive = true; } else if (mRewardCardStatus == RewardCardStatus.Lost || mRewardCardStatus == RewardCardStatus.Expired) { clsDetails.RewardActive = false; } else if (mRewardCardStatus == RewardCardStatus.Replaced_Lost || mRewardCardStatus == RewardCardStatus.Replaced_Expired || mRewardCardStatus == RewardCardStatus.Reactivated_Lost || mRewardCardStatus == RewardCardStatus.ReNew) { clsDetails.RewardActive = true; } clsDetails.RewardCardStatus = mRewardCardStatus; boRetValue = clsContactReward.Update(clsDetails); mContactDetails.RewardDetails = clsDetails; clsContactReward.CommitAndDispose(); boRetValue = true; return boRetValue; }