protected void Page_Load(object sender, EventArgs e) { //if (Session["RedemptionPrintFrieldly"] != null) //{ // string RedemptionPrintFrieldly = ""; // if (!IsPostBack) // { // RedemptionPrintFrieldly = Session["RedemptionPrintFrieldly"].ToString(); // Session.Remove("RedemptionPrintFrieldly"); // ViewState["RedemptionPrintFrieldly"] = RedemptionPrintFrieldly; // Response.Write(RedemptionPrintFrieldly); // } // else { // RedemptionPrintFrieldly = ViewState["RedemptionPrintFrieldly"].ToString(); // Response.Write(RedemptionPrintFrieldly); // } //} if (Request.QueryString["redemptionrewardid"] != null) { int redemptionrewardid = int.Parse(Request.QueryString["redemptionrewardid"]); string output = "NA"; ApplicationServices.RedemptionReward redemptionReward = ClientManager.getRedemptionReward(redemptionrewardid); // Response.Write("1"); string productname = redemptionReward.productname; string serialno = redemptionReward.serialno; int type = redemptionReward.type; int clientid = redemptionReward.clientid; int status = redemptionReward.status; //Response.Write("2"); int modeofcollection = redemptionReward.modeofcollection; int redemptionbyproductreceiptid = (int)redemptionReward.redemptionbyproductreceiptid; Guid UserId = redemptionReward.UserId; MembershipUser AdminembershipUser = Membership.GetUser(); MembershipUser membershipUser = Membership.GetUser(UserId); // Response.Write("3"); //send email bool canSendEmail; RedemptionMember redemptionMember = ClientManager.getRedemptionMember(UserId); var client = ClientManager.getClient(clientid); string emailpath = Config.MainSiteRootUrl + client.siterelativepath + client.logoimagename; Hashtable values = new Hashtable(); var redemptionByPointTransaction = ClientManager.getRedemptionByPointTransaction( redemptionbyproductreceiptid); // Response.Write("34"); if (type == (int)PromotionType.BY_POINT) { //by point int rewardpoints = (int)redemptionReward.rewardpoints; values.Add("[/logo/]", emailpath); values.Add("[/SubmissionDate/]", DateTime.Now.ToString("dd/MM/yyyy")); values.Add("[/RedemptionNo/]", redemptionrewardid); values.Add("[/ApprovedBy/]", AdminembershipUser.UserName); values.Add("[/MemberName/]", redemptionMember.firstname + " " + redemptionMember.lastname); values.Add("[/NRICNo/]", redemptionMember.NRIC); values.Add("[/ContactNo/]", redemptionMember.contactno); values.Add("[/DeliveryAddress/]", redemptionMember.mailingaddress + ", Singapore " + redemptionMember.postalcode); values.Add("[/PointsDeducted/]", rewardpoints); values.Add("[/BalancePoints/]", redemptionByPointTransaction.balance); // Response.Write("5"); switch (status) { case (int)RedemptionRewardState.ARRANGING_DELIVERY: // case (int)RedemptionRewardState.PENDING_PROCESS: case (int)RedemptionRewardState.PENDING_DELIVERY: case (int)RedemptionRewardState.PENDING_COLLECTION: values.Add("[/RedemptionItem/s/]", redemptionReward.rewardname); values.Add("[/OutstandingQuantity/]", "1"); break; case (int)RedemptionRewardState.DELIVERED: case (int)RedemptionRewardState.COLLECTED: values.Add("[/RedemptionItem/s/]", redemptionReward.rewardname); values.Add("[/OutstandingQuantity/]", "0"); break; } // Response.Write("6"); switch (modeofcollection) { case (int)CollectionMode.PICK_UP: output = EmailManager.getRedemptionByPointsSelfCollectMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); // output = "1"; break; case (int)CollectionMode.DELIVERY: output = EmailManager.getRedemptionByPointsDeliveryMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); break; } } else { //by product var redemptionByProductReceipt = ClientManager.getRedemptionByProductReceipt(redemptionbyproductreceiptid); var reseller = ClientManager.getReseller((int)redemptionByProductReceipt.resellerid); // Response.Write("8"); values.Add("[/logo/]", emailpath); values.Add("[/SubmissionDate/]", DateTime.Now.ToString("dd/MM/yyyy")); values.Add("[/RedemptionNo/]", redemptionrewardid); values.Add("[/ApprovedBy/]", AdminembershipUser.UserName); values.Add("[/MemberName/]", redemptionMember.firstname + " " + redemptionMember.lastname); values.Add("[/NRICNo/]", redemptionMember.NRIC); values.Add("[/ContactNo/]", redemptionMember.contactno); values.Add("[/DeliveryAddress/]", redemptionMember.mailingaddress + ", Singapore " + redemptionMember.postalcode); values.Add("[/Reseller/]", reseller.name); values.Add("[/InvoiceNo/]", redemptionByProductReceipt.invoiceno); values.Add("[/ItemPurchased/]", productname); values.Add("[/ItemSerialNo/]", serialno); values.Add("[/ItemQty/]", 1); // Response.Write("9"); switch (status) { case (int)RedemptionRewardState.ARRANGING_DELIVERY: // case (int)RedemptionRewardState.PENDING_PROCESS: case (int)RedemptionRewardState.PENDING_DELIVERY: case (int)RedemptionRewardState.PENDING_COLLECTION: values.Add("[/RedemptionItem/s/]", redemptionReward.rewardname); values.Add("[/OutstandingQuantity/]", "1"); break; case (int)RedemptionRewardState.DELIVERED: case (int)RedemptionRewardState.COLLECTED: values.Add("[/RedemptionItem/s/]", redemptionReward.rewardname); values.Add("[/OutstandingQuantity/]", "0"); break; } switch (modeofcollection) { case (int)CollectionMode.PICK_UP: output = EmailManager.getRedemptionByProductsSelfCollectMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); // Response.Write("10"); break; case (int)CollectionMode.DELIVERY: output = EmailManager.getRedemptionByProductsDeliveryMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); // Response.Write("11"); break; } } Response.Write(output); } }
protected void RedemptionRewardRadGrid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "process") { EmailSendLit.Text = ""; int redemptionrewardid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionrewardid"); loadRedemptionReward(redemptionrewardid); ClientDetailPnl.Visible = true; } if (e.CommandName == "SendRedemptionEmail") { int redemptionrewardid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionrewardid"); string rewardname = ((GridDataItem)e.Item).GetDataKeyValue("rewardname").ToString(); string productname = ((GridDataItem)e.Item).GetDataKeyValue("productname").ToString(); string serialno = ((GridDataItem)e.Item).GetDataKeyValue("serialno").ToString(); int type = (int)((GridDataItem)e.Item).GetDataKeyValue("type"); int clientid = (int)((GridDataItem)e.Item).GetDataKeyValue("clientid"); int status = (int)((GridDataItem)e.Item).GetDataKeyValue("status"); int modeofcollection = (int)((GridDataItem)e.Item).GetDataKeyValue("modeofcollection"); int redemptionbyproductreceiptid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionbyproductreceiptid"); Guid UserId = (Guid)((GridDataItem)e.Item).GetDataKeyValue("UserId"); MembershipUser AdminembershipUser = Membership.GetUser(); MembershipUser membershipUser = Membership.GetUser(UserId); //send email bool canSendEmail; RedemptionMember redemptionMember = ClientManager.getRedemptionMember((Guid)Membership.GetUser(UserId).ProviderUserKey); var client = ClientManager.getClient(clientid); string emailpath = Config.MainSiteRootUrl + client.siterelativepath + client.logoimagename; Hashtable values = new Hashtable(); var redemptionByPointTransaction = ClientManager.getRedemptionByPointTransaction( redemptionbyproductreceiptid); if (type == (int)PromotionType.BY_POINT) { //by point int rewardpoints = (int)((GridDataItem)e.Item).GetDataKeyValue("rewardpoints"); values.Add("[/logo/]", emailpath); values.Add("[/SubmissionDate/]", DateTime.Now.ToString("dd/MM/yyyy")); values.Add("[/RedemptionNo/]", redemptionrewardid); values.Add("[/ApprovedBy/]", AdminembershipUser.UserName); values.Add("[/MemberName/]", redemptionMember.firstname + " " + redemptionMember.lastname); values.Add("[/NRICNo/]", redemptionMember.NRIC); values.Add("[/ContactNo/]", redemptionMember.contactno); values.Add("[/DeliveryAddress/]", redemptionMember.mailingaddress + ", Singapore " + redemptionMember.postalcode); values.Add("[/PointsDeducted/]", rewardpoints); values.Add("[/BalancePoints/]", redemptionByPointTransaction.balance); switch (status) { case (int)RedemptionRewardState.ARRANGING_DELIVERY: // case (int)RedemptionRewardState.PENDING_PROCESS: case (int)RedemptionRewardState.PENDING_DELIVERY: case (int)RedemptionRewardState.PENDING_COLLECTION: values.Add("[/RedemptionItem/s/]", rewardname); values.Add("[/OutstandingQuantity/]", "1"); break; case (int)RedemptionRewardState.DELIVERED: case (int)RedemptionRewardState.COLLECTED: values.Add("[/RedemptionItem/s/]", rewardname); values.Add("[/OutstandingQuantity/]", "0"); break; } switch (modeofcollection) { case (int)CollectionMode.PICK_UP: canSendEmail = EmailManager.SendRedemptionByPointsSelfCollectMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); break; case (int)CollectionMode.DELIVERY: canSendEmail = EmailManager.SendRedemptionByPointsDeliveryMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); break; } EmailSendLit.Text = "Redemption email is sent for Redemption ID:" + redemptionrewardid; } else { //by product var redemptionByProductReceipt = ClientManager.getRedemptionByProductReceipt(redemptionbyproductreceiptid); var reseller = ClientManager.getReseller((int)redemptionByProductReceipt.resellerid); values.Add("[/logo/]", emailpath); values.Add("[/SubmissionDate/]", DateTime.Now.ToString("dd/MM/yyyy")); values.Add("[/RedemptionNo/]", redemptionrewardid); values.Add("[/ApprovedBy/]", AdminembershipUser.UserName); values.Add("[/MemberName/]", redemptionMember.firstname + " " + redemptionMember.lastname); values.Add("[/NRICNo/]", redemptionMember.NRIC); values.Add("[/ContactNo/]", redemptionMember.contactno); values.Add("[/DeliveryAddress/]", redemptionMember.mailingaddress + ", Singapore " + redemptionMember.postalcode); values.Add("[/Reseller/]", reseller.name); values.Add("[/InvoiceNo/]", redemptionByProductReceipt.invoiceno); values.Add("[/ItemPurchased/]", productname); values.Add("[/ItemSerialNo/]", serialno); values.Add("[/ItemQty/]", 1); switch (status) { case (int)RedemptionRewardState.ARRANGING_DELIVERY: // case (int)RedemptionRewardState.PENDING_PROCESS: case (int)RedemptionRewardState.PENDING_DELIVERY: case (int)RedemptionRewardState.PENDING_COLLECTION: values.Add("[/RedemptionItem/s/]", rewardname); values.Add("[/OutstandingQuantity/]", "1"); break; case (int)RedemptionRewardState.DELIVERED: case (int)RedemptionRewardState.COLLECTED: values.Add("[/RedemptionItem/s/]", rewardname); values.Add("[/OutstandingQuantity/]", "0"); break; } switch (modeofcollection) { case (int)CollectionMode.PICK_UP: canSendEmail = EmailManager.SendRedemptionByProductsSelfCollectMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); break; case (int)CollectionMode.DELIVERY: canSendEmail = EmailManager.SendRedemptionByProductsDeliveryMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); break; } EmailSendLit.Text = "Redemption email is sent for Redemption ID:" + redemptionrewardid; Logger.LogInfo(Membership.GetUser().UserName + "- Redemption email is sent for Redemption ID:" + redemptionrewardid , this.GetType()); } } //if (e.CommandName == "PrintFriendly") //{ // int redemptionrewardid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionrewardid"); // //Session.Add("RedemptionPrintFrieldly", "lalalalalala"); // Response.Redirect("RedemptionPrintFriendly.aspx?redemptionrewardid=" + redemptionrewardid); //} }
protected void ReeemBut_Click(object sender, EventArgs e) { if (Request.QueryString["rewardid"] != null && Request.QueryString["promotionid"] != null) { var db = new ApplicationServices.ApplicationServicesDB(); using (var scope = db.GetTransaction()) { int rewardid = int.Parse(Request.QueryString["rewardid"]); int promotionid = int.Parse(Request.QueryString["promotionid"]); var redemptionMemberClient = ClientManager.getRedemptionMemberClient( (Guid)Membership.GetUser().ProviderUserKey, Config.ClientId); var reward = ClientManager.getReward(rewardid); var promotion = ClientManager.getPromotion(promotionid); int newPointBalance = redemptionMemberClient.pointbalance - reward.points; //check before transaction if (newPointBalance >= 0) { int redemptionRewardState = -1; switch (int.Parse(CollectionModeRBL.SelectedValue)) { case (int)CollectionMode.PICK_UP: redemptionRewardState = (int)RedemptionRewardState.PENDING_COLLECTION; break; case (int)CollectionMode.DELIVERY: redemptionRewardState = (int)RedemptionRewardState.PENDING_DELIVERY; break; } //insert redemptinoreward item int redemptionrewardid = ClientManager.insertRedemptionReward( Config.ClientId, (Guid)Membership.GetUser().ProviderUserKey, promotion.promotionid, promotion.name, -1, "", reward.rewardid, reward.name, reward.points, int.Parse(CollectionModeRBL.SelectedValue), "", RemarksTB.Text.Trim(), (int)PromotionType.BY_POINT, redemptionRewardState, -1); //reduce qty of reward by 1 ClientManager.reduceRewardQtyBy1(reward.rewardid); //add entry to point transactino string notes = "Redemption ID:" + redemptionrewardid + " | Points:" + reward.points; int RedemptionByPointTransactionid = ClientManager.insertRedemptionByPointTransaction( (Guid)Membership.GetUser().ProviderUserKey, Config.ClientId, (int)RedemptionByPointTransactionType.REDEMPTION, reward.points, newPointBalance, notes); //update redemptionreward the redemption id ClientManager.updateRedemptionRewardTransactionId( redemptionrewardid, RedemptionByPointTransactionid); //update redemptionmember point balance ClientManager.updateRedemptionMemberClientBalance( (Guid)Membership.GetUser().ProviderUserKey, Config.ClientId, newPointBalance); scope.Complete(); //send email bool canSendEmail; RedemptionMember redemptionMember = ClientManager.getRedemptionMember((Guid)Membership.GetUser().ProviderUserKey); Client client = ClientManager.getClient(Config.ClientId); string emailLogoUrl = Config.SiteRootUrl + client.logoimagename; Hashtable values = new Hashtable(); values.Add("[/logo/]", emailLogoUrl); values.Add("[/SubmissionDate/]", DateTime.Now.ToString("dd/MM/yyyy")); values.Add("[/RedemptionNo/]", redemptionrewardid); values.Add("[/ApprovedBy/]", "System"); values.Add("[/MemberName/]", redemptionMember.firstname + " " + redemptionMember.lastname); values.Add("[/NRICNo/]", redemptionMember.NRIC); values.Add("[/ContactNo/]", redemptionMember.contactno); values.Add("[/DeliveryAddress/]", redemptionMember.mailingaddress + ", Singapore " + redemptionMember.postalcode); values.Add("[/PointsDeducted/]", reward.points); values.Add("[/BalancePoints/]", newPointBalance); values.Add("[/RedemptionItem/s/]", reward.name); values.Add("[/OutstandingQuantity/]", "1"); switch (int.Parse(CollectionModeRBL.SelectedValue)) { case (int)CollectionMode.PICK_UP: canSendEmail = EmailManager.SendRedemptionByPointsSelfCollectMail( Membership.GetUser().Email, redemptionMember.firstname, values, this.Response); break; case (int)CollectionMode.DELIVERY: canSendEmail = EmailManager.SendRedemptionByPointsDeliveryMail( Membership.GetUser().Email, redemptionMember.firstname, values, this.Response); break; } Response.Redirect("RedeemByPointsAck.aspx"); } else { //not enough points } } } }
protected void RedemptionRewardRadGrid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { //if (e.CommandName == "delete2") //{ // int redemptionbypointreceiptItemid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionbypointreceiptitemid"); // int redemptionbypointreceiptid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionbypointreceiptid"); // ClientManager.deleteRedemptionByPointReceiptItem(redemptionbypointreceiptItemid); // var x = ClientManager.getAllRedemptionByPointReceiptReceiptId(redemptionbypointreceiptid); // ReceiptItemRadGrid.DataSource = x; // ReceiptItemRadGrid.Rebind(); // List<RedemptionByPointReceiptItem> list = (List<RedemptionByPointReceiptItem>)x; // int total = 0; // foreach (RedemptionByPointReceiptItem item in list) // { // total += item.productpoints; // } // // totalpointsLit.Text = total.ToString(); // ClientManager.updateRedemptionByPointReceiptPoint(redemptionbypointreceiptid, total); //} if (e.CommandName == "SendRedemptionEmail") { int redemptionrewardid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionrewardid"); string productname = ((GridDataItem)e.Item).GetDataKeyValue("productname").ToString(); string serialno = ((GridDataItem)e.Item).GetDataKeyValue("serialno").ToString(); int type = (int)((GridDataItem)e.Item).GetDataKeyValue("type"); int clientid = (int)((GridDataItem)e.Item).GetDataKeyValue("clientid"); int status = (int)((GridDataItem)e.Item).GetDataKeyValue("status"); int modeofcollection = (int)((GridDataItem)e.Item).GetDataKeyValue("modeofcollection"); int redemptionbyproductreceiptid = (int)((GridDataItem)e.Item).GetDataKeyValue("redemptionbyproductreceiptid"); Guid UserId = (Guid)((GridDataItem)e.Item).GetDataKeyValue("UserId"); MembershipUser AdminembershipUser = Membership.GetUser(); MembershipUser membershipUser = Membership.GetUser(UserId); ApplicationServices.RedemptionReward redemptionReward = ClientManager.getRedemptionReward(redemptionrewardid); //send email bool canSendEmail; RedemptionMember redemptionMember = ClientManager.getRedemptionMember((Guid)Membership.GetUser(UserId).ProviderUserKey); var client = ClientManager.getClient(clientid); string emailpath = Config.MainSiteRootUrl + client.siterelativepath + client.logoimagename; Hashtable values = new Hashtable(); var redemptionByPointTransaction = ClientManager.getRedemptionByPointTransaction( redemptionbyproductreceiptid); //by product var redemptionByProductReceipt = ClientManager.getRedemptionByProductReceipt(redemptionbyproductreceiptid); var reseller = ClientManager.getReseller((int)redemptionByProductReceipt.resellerid); values.Add("[/logo/]", emailpath); values.Add("[/SubmissionDate/]", DateTime.Now.ToString("dd/MM/yyyy")); values.Add("[/RedemptionNo/]", redemptionrewardid); values.Add("[/ApprovedBy/]", AdminembershipUser.UserName); values.Add("[/MemberName/]", redemptionMember.firstname + " " + redemptionMember.lastname); values.Add("[/NRICNo/]", redemptionMember.NRIC); values.Add("[/ContactNo/]", redemptionMember.contactno); values.Add("[/DeliveryAddress/]", redemptionMember.mailingaddress + ", Singapore " + redemptionMember.postalcode); values.Add("[/Reseller/]", reseller.name); values.Add("[/InvoiceNo/]", redemptionByProductReceipt.invoiceno); values.Add("[/ItemPurchased/]", productname); values.Add("[/ItemSerialNo/]", serialno); values.Add("[/ItemQty/]", 1); switch (status) { case (int)RedemptionRewardState.ARRANGING_DELIVERY: // case (int)RedemptionRewardState.PENDING_PROCESS: case (int)RedemptionRewardState.PENDING_DELIVERY: case (int)RedemptionRewardState.PENDING_COLLECTION: values.Add("[/RedemptionItem/s/]", redemptionReward.rewardname); values.Add("[/OutstandingQuantity/]", "1"); break; case (int)RedemptionRewardState.DELIVERED: case (int)RedemptionRewardState.COLLECTED: values.Add("[/RedemptionItem/s/]", redemptionReward.rewardname); values.Add("[/OutstandingQuantity/]", "0"); break; } switch (modeofcollection) { case (int)CollectionMode.PICK_UP: canSendEmail = EmailManager.SendRedemptionByProductsSelfCollectMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); break; case (int)CollectionMode.DELIVERY: canSendEmail = EmailManager.SendRedemptionByProductsDeliveryMail( membershipUser.UserName, redemptionMember.firstname, values, client.clientid, this.Response); break; } EmailSendLit.Text = "Redemption email is sent for Redemption ID:" + redemptionrewardid; } }