Example #1
0
    protected void rpFixamount_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "FixAmount")
        {
            if ((e.Item.ItemType == ListItemType.Item) || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Label   lblfixamount = (Label)e.Item.FindControl("lblFixamount");
                TextBox txtamount    = (TextBox)e.Item.FindControl("txtAmounts");
                if (txtamount.Text == "")
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = "Enter the new value of add amout.";
                    return;
                }
                Label   lblwalletamount = (Label)e.Item.FindControl("lblWalletamt");
                decimal walletblce      = 0;
                if (lblwalletamount.Text != "0")
                {
                    walletblce = Convert.ToDecimal(lblwalletamount.Text);
                }
                decimal fixamount = 0;
                if (lblfixamount.Text != "")
                {
                    fixamount = Convert.ToDecimal(lblfixamount.Text);
                }
                decimal addedamount   = Convert.ToDecimal(txtamount.Text);
                decimal fixamounts    = fixamount + addedamount;
                string  useridetifyno = GetUserIdentifyNo(Convert.ToString(Session["userid"]));
                Int32   userid        = Convert.ToInt32(Session["userid"]);
                decimal percent       = getPercetage();
                int     result        = 0;

                if (walletblce != 0)
                {
                    try
                    {
                        if (local_wallet.IsFixExists(userid) == "T")
                        {
                            result = local_wallet.AddNewFixAmount(fixamounts, addedamount, useridetifyno, userid, percent);
                            local_wallet.UpdateCustomerWalletFundtransfer(addedamount, userid);
                            if (result != 0)
                            {
                                string user = Convert.ToString(Session["userid"]);
                                BindFixAmountDetail(user);
                                BindToFixAmount(user);
                                mpe.Show();
                                lblpopup.Text = "Your amount added to fixed amount.";
                                //lblMessage.ForeColor = Color.Green;
                                //lblMessage.Text = "Your amount added to fixed amount.";
                            }
                        }
                        else
                        {
                            string monthcount = "Month Begin";
                            result = local_wallet.AddNewFixAmountFirst(fixamounts, addedamount, useridetifyno, monthcount, userid, percent);
                            local_wallet.UpdateCustomerWalletFundtransfer(addedamount, userid);
                            if (result != 0)
                            {
                                string user = Convert.ToString(Session["userid"]);
                                BindFixAmountDetail(user);
                                BindToFixAmount(user);
                                mpe.Show();
                                lblpopup.Text = "Your amount added to fixed amount.";
                                //lblMessage.ForeColor = Color.Green;
                                //lblMessage.Text = "Your amount added to fixed amount.";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        lblMessage.ForeColor = Color.Red;
                        lblMessage.Text      = ex.Message;
                    }
                }
                else
                {
                    mpe.Show();
                    lblpopup.Text = "You haven't enough wallet balance to fix amount.";
                    //lblMessage.ForeColor = Color.Red;
                    //lblMessage.Text = "You haven't enough wallet balance to fix amount.";
                }
            }
        }

        if (e.CommandName == "DetachAmount")
        {
            if ((e.Item.ItemType == ListItemType.Item) || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Label   lblfixamount    = (Label)e.Item.FindControl("lblFixamount");
                TextBox txtamount       = (TextBox)e.Item.FindControl("txtAmounts");
                Label   lblwalletamount = (Label)e.Item.FindControl("lblWalletamt");
                if (txtamount.Text == "")
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = "Enter the new value of deduct amount.";
                    return;
                }
                decimal walletblce = 0;
                if (lblwalletamount.Text != "0.00")
                {
                    walletblce = Convert.ToDecimal(lblwalletamount.Text);
                }
                decimal fixamount = 0;
                if (lblfixamount.Text != "")
                {
                    fixamount = Convert.ToDecimal(lblfixamount.Text);
                }
                decimal deductamount = Convert.ToDecimal(txtamount.Text);

                string  useridetifyno = GetUserIdentifyNo(Convert.ToString(Session["userid"]));
                Int32   userid        = Convert.ToInt32(Session["userid"]);
                decimal percent       = getPercetage();

                int result = 0;
                try
                {
                    if (local_wallet.IsFixExists(userid) == "T")
                    {
                        if (fixamount >= deductamount)
                        {
                            fixamount = fixamount - deductamount;

                            result = local_wallet.DeductNewFixAmount(fixamount, deductamount, useridetifyno, userid, percent);
                            local_wallet.UpdateCustomerWalletDeductAdd(deductamount, userid);
                            if (result != 0)
                            {
                                string user = Convert.ToString(Session["userid"]);
                                BindFixAmountDetail(user);
                                BindToFixAmount(user);
                                mpe.Show();
                                lblpopup.Text = "Amount detached from fixed amount.";
                                //lblMessage.ForeColor = Color.Green;
                                //lblMessage.Text = "Amount detached from fixed amount.";
                            }
                        }
                        else
                        {
                            mpe.Show();
                            lblpopup.Text = "You have not enough fixed amount to deduct.";
                            //lblMessage.ForeColor = Color.Red;
                            //lblMessage.Text = "You have not enough fixed amount to deduct.";
                        }
                    }
                    else
                    {
                        mpe.Show();
                        lblpopup.Text = "You haven't fixed amount to detach.";
                        //lblMessage.ForeColor = Color.Red;
                        //lblMessage.Text = "You haven't fixed amount to detach.";
                    }
                }
                catch (Exception ex)
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = ex.Message;
                }
            }
        }
    }