Thursday, August 2, 2018

how to create Book Management system in Asp.net : Sradha WebCreations

how to create Book Management system in Asp.net

 http://sradhawebcreations.com/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
using System.Configuration;

public partial class COMBO_BOX_DISCOUNT_ON_BOOKS : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DropDownListCUSTOMERTYPE.Items.Add("SELECT 1");
        DropDownListCUSTOMERTYPE.Items.Add("LIBRARY");
        DropDownListCUSTOMERTYPE.Items.Add("BOOK STORE");
        DropDownListCUSTOMERTYPE.Items.Add("PRIVATE");
        DropDownListCUSTOMERTYPE.Items.Add("OTHER");
    }
    protected void DropDownListCUSTOMERTYPE_SelectedIndexChanged(object sender, EventArgs e)
    {
        int iNumberOfBook = Convert.ToInt32(TextBoxNUMBEROFBOOK.Text);
        double dPerBookCost = Convert.ToDouble(TextBoxPERBOOKCOST.Text);
        double dTotal;
        double dTotalCostAfterDiscount;
        double dDiscount;
        double DdiscountAmount;
        //string sCustomerType = DropDownListCUSTOMERTYPE.Text;
       
        //if (sCustomerType == "library" || sCustomerType == "book store" || sCustomerType == "private")
        if (DropDownListCUSTOMERTYPE.SelectedIndex == 1 || DropDownListCUSTOMERTYPE.SelectedIndex == 2 || DropDownListCUSTOMERTYPE.SelectedIndex == 3)
        {
            dDiscount = 20;
            TextBoxDISCONT.Text = Convert.ToString(dDiscount + "%");

            dTotal = dPerBookCost * iNumberOfBook;
            TextBoxTOTALCOST.Text = Convert.ToString("Rs" + dTotal);

            DdiscountAmount = dTotal * dDiscount / 100;
            TextBoxDISCOUNTAMOUNT.Text = Convert.ToString("Rs" + DdiscountAmount);

            dTotalCostAfterDiscount = dTotal - DdiscountAmount;
            TextBoxTOTALCOSTAFTERDISCOUNT.Text = Convert.ToString("Rs" + dTotalCostAfterDiscount);

        }
        else
        {
            if (iNumberOfBook >= 10 && iNumberOfBook <= 30)
            {
                dDiscount = 5;
             TextBoxDISCONT.Text = Convert.ToString(dDiscount + "%");
                dTotal = dPerBookCost * iNumberOfBook;
             TextBoxTOTALCOST.Text = Convert.ToString("Rs" + dTotal);

                DdiscountAmount = dTotal * dDiscount / 100;
TextBoxDISCOUNTAMOUNT.Text = Convert.ToString("Rs" + DdiscountAmount);
                dTotalCostAfterDiscount = dTotal - DdiscountAmount;
TextBoxTOTALCOSTAFTERDISCOUNT.Text = Convert.ToString("Rs" + dTotalCostAfterDiscount);
            }
            else if (iNumberOfBook > 30 && iNumberOfBook <= 60)
            {
                dDiscount = 10;
           TextBoxDISCONT.Text = Convert.ToString(dDiscount + "%");

                dTotal = dPerBookCost * iNumberOfBook;
             TextBoxTOTALCOST.Text = Convert.ToString("Rs" + dTotal);

                DdiscountAmount = dTotal * dDiscount / 100;
TextBoxDISCOUNTAMOUNT.Text = Convert.ToString("Rs" + DdiscountAmount);

dTotalCostAfterDiscount = dTotal - DdiscountAmount;
                TextBoxTOTALCOSTAFTERDISCOUNT.Text = Convert.ToString("Rs" + dTotalCostAfterDiscount);
            }
            else
            {
                dDiscount = 20;
         TextBoxDISCONT.Text = Convert.ToString(dDiscount + "%");

                dTotal = dPerBookCost * iNumberOfBook;
         TextBoxTOTALCOST.Text = Convert.ToString("Rs" + dTotal);

                DdiscountAmount = dTotal * dDiscount / 100;
TextBoxDISCOUNTAMOUNT.Text = Convert.ToString("Rs" + DdiscountAmount);

                dTotalCostAfterDiscount = dTotal - DdiscountAmount;
TextBoxTOTALCOSTAFTERDISCOUNT.Text = Convert.ToString("Rs" + dTotalCostAfterDiscount);
            }
        }

    }
    protected void ButtonSAVE_Click(object sender, EventArgs e)
    {
        String connectionString= ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        string insertsql = "insert into discount1 (numberofbook,perbook,customertype,discount,totalcost,discountamount,totalcostafterdiscount)values(@numberofbook,@perbook,@customertype,@discount,@totalcost,@discountamount,@totalcostafterdiscount)";

        using (SqlConnection myconnection = new SqlConnection(connectionString))
        {
            myconnection.Open();
            SqlCommand mycommand = new SqlCommand(insertsql, myconnection);
            mycommand.Parameters.AddWithValue("@numberofbook", TextBoxNUMBEROFBOOK.Text);
            mycommand.Parameters.AddWithValue("@perbook", TextBoxPERBOOKCOST.Text);
            mycommand.Parameters.AddWithValue("@customertype", DropDownListCUSTOMERTYPE.Text);
            mycommand.Parameters.AddWithValue("@discount", TextBoxDISCONT.Text);
            mycommand.Parameters.AddWithValue("@totalcost", TextBoxTOTALCOST.Text);
            mycommand.Parameters.AddWithValue("@discountamount", TextBoxDISCOUNTAMOUNT.Text);
            mycommand.Parameters.AddWithValue("@totalcostAfterDiscount", TextBoxTOTALCOSTAFTERDISCOUNT.Text);

            mycommand.ExecuteNonQuery();
            myconnection.Close();
        }
        TextBoxNUMBEROFBOOK.Text = string.Empty;
        TextBoxPERBOOKCOST.Text = string.Empty;
        //DropDownListCUSTOMERTYPE.Text = string.Empty;
        TextBoxDISCONT.Text = string.Empty;
        TextBoxTOTALCOST.Text = string.Empty;
        TextBoxDISCOUNTAMOUNT.Text = string.Empty;
        TextBoxTOTALCOSTAFTERDISCOUNT.Text = string.Empty;
        Label1.Text = "DATA INSERT SUCCESSFULLY";
         }
}







Wednesday, August 1, 2018

how to create data picker using dropdown list and text box : Sradha WebCreations

how to create data picker using drop down list and text box asp.net , sql server 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class OR_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int i;
        for (i = 1; i <= 31; i++)
        {
            DropDownListDAY.Items.Add(Convert.ToString(i));
        }
        DropDownListMONTH.Items.Add("JAN");
        DropDownListMONTH.Items.Add("FEB");
        DropDownListMONTH.Items.Add("MAR");
        DropDownListMONTH.Items.Add("APR");
        DropDownListMONTH.Items.Add("MAY");
        DropDownListMONTH.Items.Add("JUN");
        DropDownListMONTH.Items.Add("JUL");
        DropDownListMONTH.Items.Add("AUG");
        DropDownListMONTH.Items.Add("SEPT");
        DropDownListMONTH.Items.Add("NOV");
        DropDownListMONTH.Items.Add("DEC");

        int X;
        for (X = 1900; X <= 2000; X++)
        {
            DropDownListYEAR.Items.Add(Convert.ToString(X));
        }
    }

    string sday;
    string sMonth;
    string sYear ;

    protected void ButtonDATE_Click(object sender, EventArgs e)
   
{
        sday = Convert.ToString(DropDownListDAY.SelectedItem.Text);

        sMonth = Convert.ToString(DropDownListMONTH.SelectedItem.Text);

        sYear = Convert.ToString(DropDownListYEAR.SelectedItem.Text);

       // string sDate = sday + "/" + sMonth + "/" + sYear;
        string sDate=DropDownListDAY.SelectedItem.Text+"/"+DropDownListMONTH.SelectedItem.Text+"/"+DropDownListYEAR.SelectedItem.Text;
     
  Convert.ToString( TextBoxDATE.Text=sDate );

    }
}







how to create bus ticket booking Management system | Sradha WebCreations

bus ticket booking  Management system



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class IF_ELSE_AND_OR_TRANSPORT : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
protected void TextBoxKILOMETER_TextChanged(object sender,EventArgs e)
    {
        string sName = textboxNAME.Text;
        string sSeatNumber = TextBoxseatnumber.Text;
        string sJDate = TextBoxjourning.Text;
        int iKiloMeter = Convert.ToInt32(TextBoxKILOMETER.Text);
       
        double dMinimumCharge;
        int iExtraKilometer;
       
        iExtraKilometer = iKiloMeter - 25;
        TextBoxEXTRAKILOMETER.Text = Convert.ToString(iExtraKilometer);            
        double dExtraCharge;
        double dTotalCharge;
     
        if (iKiloMeter <= 25)
        {
            dMinimumCharge = 25.00;
        
            dExtraCharge = 0;
            dTotalCharge = dMinimumCharge + dExtraCharge;
        }
        else if(iKiloMeter>25 && iKiloMeter<=50)
        {
            dMinimumCharge=25.00;
            dExtraCharge = 15.00;
            dTotalCharge = dMinimumCharge + dExtraCharge;
         }
        else if (iKiloMeter > 50 && iKiloMeter <= 75)
        {
            dMinimumCharge = 25.00;
            dExtraCharge = 15.00+15.00;
            dTotalCharge = dMinimumCharge + dExtraCharge;
        }
        else if (iKiloMeter > 75 && iKiloMeter <= 100)
        {
            dMinimumCharge = 25.00;
            dExtraCharge = 15.00 + 15.00 + 15.00;
            dTotalCharge = dMinimumCharge + dExtraCharge;
        }
        else if (iKiloMeter > 100 && iKiloMeter <= 125)
        {
            dMinimumCharge = 25.00;
            dExtraCharge = 15.00+15.00+15.00+15.00;
            dTotalCharge = dMinimumCharge + dExtraCharge;
        }
        else
        {
            dMinimumCharge = 25.00;
            dExtraCharge = 15.00 + 15.00 + 15.00 + 15.00;
            dTotalCharge = dMinimumCharge + dExtraCharge;
        }
      
 TextBoxMINIMUMCHARGE.Text = Convert.ToString(dMinimumCharge);
        TextBoxEXTRAKILOMETERCHARGE.Text = Convert.ToString(dExtraCharge);
        TextBoxTOTALCHARGE.Text = Convert.ToString(dTotalCharge);
        }
   
}