Monday, 30 July 2012

Source code for New user in CCFD - 4


                    //To Get all the transaction palce and amount to verify the current transction

                    data.DBReaderOpen("Select * from account where cardNo='" + txtCardNo.Text + "'");

                    if (data.dr.HasRows)
                    {
                        while (data.dr.Read())
                        {
                            if (data.dr["PlaceofTransaction"].ToString() == txtPalce.Text)
                            {
                                Place = true;
                                break;
                            }
                        }

                    }
                    data.DBReaderClose();


                    data.DBReaderOpen("select min(amount) as Min ,max(amount) as max from account where cardNo='" + txtCardNo.Text + "'");

                    if (data.dr.HasRows)
                    {
                        data.dr.Read();
                        {
                            int min = Convert.ToInt32(data.dr["Min"].ToString());
                            int max = Convert.ToInt32(data.dr["Max"].ToString());

                            if (min <= Convert.ToInt32(txtAmt.Text) && max >= Convert.ToInt32(txtAmt.Text))
                            {
                                Amt = true;
                            }
                        }

                    }


                    if (Amt && Place)
                    {
                        insertData();
                    }
                    else if (Amt)
                    {
                        insertData();
                    }
                    else
                    {
                        data.DBReaderOpen("Select uid from userInfo where cardNo='" + txtCardNo.Text + "'");
                        if (data.dr.HasRows)
                        {
                            data.dr.Read();
                            {
                                Session["TranUid"] = data.dr["uid"].ToString();
                                Session["CardNo"] = txtCardNo.Text;
                                Session["AccountNo"] = txtACNO.Text;
                                Session["BankName"] = txtBankName.Text;
                                Session["HolderName"] = txtACName.Text;
                                Session["Address"] = txtAddress.Text;
                                Session["Place"] = txtPalce.Text;
                                Session["PlaceId"] = txtPlaceId.Text;
                                Session["Amt"] = txtAmt.Text;
                                Session["SumAmount"] = sumAmount;
                                Session["creditLimit"] = CreditLimit;
                                Response.Redirect("pgVerification.aspx");
                            }
                        }
                    }


                }

            }

        }
    }
    void insertData()
    {

        if (Convert.ToInt32(txtAmt.Text) + sumAmount <= CreditLimit)
        {
            data.DBOpen();

            data.cmd = new SqlCommand("Account_SP", data.cn);
            data.cmd.CommandType = CommandType.StoredProcedure;

            data.cmd.Parameters.Add(new SqlParameter("@cardNo", txtCardNo.Text));
            data.cmd.Parameters.Add(new SqlParameter("@holderName", txtACName.Text));
            data.cmd.Parameters.Add(new SqlParameter("@HolderAddress", txtAddress.Text));
            data.cmd.Parameters.Add(new SqlParameter("@ACNO", txtACNO.Text));
            data.cmd.Parameters.Add(new SqlParameter("@BankName", txtBankName.Text));
            data.cmd.Parameters.Add(new SqlParameter("@PlaceofTransaction", txtPalce.Text));
            data.cmd.Parameters.Add(new SqlParameter("@PlaceId", Convert.ToInt32(txtPlaceId.Text)));
            data.cmd.Parameters.Add(new SqlParameter("@Amount", Convert.ToInt32(txtAmt.Text)));
            data.cmd.Parameters.Add(new SqlParameter("@DateTime", DateTime.Now));

            data.cmd.ExecuteNonQuery();
            data.DBCmdClose();
        }
        else
        {
            lblError.Text = "Sorry You are Exceed the Credit Limit";
            lblError.Visible = true;
        }

        txtPalce.Text = "";
        txtPlaceId.Text = "";
        txtCardNo.Text = "";
        txtBankName.Text = "";
        txtAmt.Text = "";
        txtAddress.Text = "";
        txtACNO.Text = "";
        txtACName.Text = "";
    }
}

No comments:

Post a Comment