Example #1
0
        protected void DeleteBut_Click(object sender, EventArgs e)
        {
            int redemptionrewardid = int.Parse(UpdateRedemptionBut.CommandArgument);
            var db = new ApplicationServices.ApplicationServicesDB();

            using (var scope = db.GetTransaction())
            {
                ApplicationServices.RedemptionReward redemptionReward = ClientManager.getRedemptionReward(redemptionrewardid);

                int rewardid = redemptionReward.rewardid;
                var redemptionMemberClient = ClientManager.getRedemptionMemberClient(
                    redemptionReward.UserId, redemptionReward.clientid);

                //add stock back to reward balance
                ClientManager.increaseRewardQtyBy1(rewardid);

                //if by points
                if (redemptionReward.type == (int)PromotionType.BY_POINT)
                {
                    int newPointBalance = redemptionMemberClient.pointbalance + redemptionReward.rewardpoints;

                    //return points
                    ClientManager.updateRedemptionMemberClientBalance(redemptionReward.UserId,
                                                                      redemptionReward.clientid,
                                                                      newPointBalance);
                    string notes = "VOID | Redemption ID:" + redemptionReward.redemptionrewardid + " | Points:" + redemptionReward.rewardpoints;
                    //add void transaction
                    ClientManager.insertRedemptionByPointTransaction(
                        redemptionReward.UserId,
                        redemptionReward.clientid,
                        (int)RedemptionByPointTransactionType.DEBIT,
                        redemptionReward.rewardpoints,
                        newPointBalance,
                        notes);
                }

                ClientManager.deleteRedemptionReward(
                    redemptionrewardid);
                ClientDetailPnl.Visible = false;

                scope.Complete();
                Logger.LogInfo(Membership.GetUser().UserName + "- deleted and return stock for Redemption ID:" + redemptionrewardid
                               , this.GetType());
            }

            RedemptionRewardRadGrid.Rebind();
        }
        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);
            }
        }
Example #3
0
        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;
            }
        }