Example #1
0
    protected void btn_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtMobileNumber.Text.Trim() != "" && ddloperator.SelectedIndex != 0 && txtAmount.Text.Trim() != "")
            {
                if (Convert.ToDecimal(Master.Amount) >= Convert.ToDecimal(txtAmount.Text.Trim()))
                {
                    Recharge objRecharge = new Recharge();

                    objRecharge.Amount       = Convert.ToDecimal(txtAmount.Text.Trim());
                    objRecharge.MobileNo     = txtMobileNumber.Text.Trim();
                    objRecharge.OperatorCode = ddloperator.SelectedValue.ToString();
                    objRecharge.CreatedDate  = DateTime.UtcNow.AddHours(5).AddMinutes(30).ToString("yyyy-MM-dd hh:mm:ss tt");
                    objRecharge.UserId       = Convert.ToInt32(Session["UserId"].ToString());
                    objRecharge.Area         = ddlArea.SelectedItem.ToString();

                    DataSet objDataSet = Recharge.Send_Data_To_DB(objRecharge);
                    if (Convert.ToInt32(objDataSet.Tables[0].Rows[0][0].ToString()) > 0)
                    {
                        string output;
                        output = Recharge.Recharge_Bal(txtMobileNumber.Text.Trim(), Convert.ToDecimal(txtAmount.Text.Trim()), ddloperator.SelectedValue.ToString(), objDataSet.Tables[0].Rows[0][0].ToString());

                        if (output == "1200")
                        {
                            ShowNotification("Recharge", "Recharged Successfully..", NotificationType.success);
                            Master.Amount = (Convert.ToDecimal(Master.Amount) - Convert.ToDecimal(txtAmount.Text.Trim())).ToString();
                        }
                        else
                        {
                            ShowNotification("Recharge", "ohh Some isue...", NotificationType.error);
                            Master.Amount = (Convert.ToDecimal(Master.Amount) - Convert.ToDecimal(txtAmount.Text.Trim())).ToString();
                        }


                        clear();
                    }
                }
                else
                {
                    ShowNotification("Recharge", "Invalid Amount..!", NotificationType.error);
                    txtAmount.Focus();
                }
            }
            else
            {
                ShowNotification("Recharge", "Please Fill All Fields..!", NotificationType.error);
            }
        }
        catch (Exception Ex)
        {
            StackTrace objStackTrace    = new StackTrace();
            string     calledMethodName = objStackTrace.GetFrame(1).GetMethod().Name;
            string     dispErrorMsg     = string.Format("Error occurred in {0} method.", calledMethodName);
            LogFile.WriteToLog(dispErrorMsg, Ex);
            ShowNotification("Recharge", dispErrorMsg, NotificationType.error);
        }
    }