Showing posts with label asp.net calculations. Show all posts
Showing posts with label asp.net calculations. Show all posts

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";
         }
}







Saturday, July 28, 2018

how to create Phone call Database management system | sradha webcreations

Phone call Database management system in 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;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;

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

    }
    protected void TextBox3_TextChanged(object sender, EventArgs e)
    {
        string sCustomerName = TextBoxCUSTOMERNAME.Text;
        string sPhoneNumber = TextBoxPHONENUMBER.Text;
        int iTotalCall =Convert.ToInt32( TextBoxTOTALCALL.Text);
       
        int iExtraCall;
        iExtraCall = iTotalCall - 200;

        int iExtraCall400;
        iExtraCall400=iTotalCall-400;

        int iExtraCall600;
        iExtraCall600=iTotalCall-600;

        double dCallCharge;
      
        if (iTotalCall <= 200)
        {
            dCallCharge = 200;
        }
        else if (iTotalCall > 200 && iTotalCall <= 400)
        {
            dCallCharge=200+(iExtraCall*1.50);
        }
        else if (iTotalCall > 400 && iTotalCall <= 600)
        {
            dCallCharge = 200 + (200 * 1.50) + (iExtraCall400 * 2.50);
        }
        else
        {
            dCallCharge=200+(200*1.50)+(200*2.50)+(iExtraCall600*3.50);

        }
        TextBoxCALLCHARGE.Text = Convert.ToString(dCallCharge);
    }
    }




Tuesday, July 24, 2018

how to calculate PERIMETER OF RECTANGULAR in asp.net | sradha webcreations

PERIMETER OF RECTANGULAR
              ENTER WIDTH

             ENTER HEIGHT

  PERIMETER OF RECTANGULAR


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

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

    }
  
 protected void BTNCALCULATE_Click(object sender, EventArgs e)
    {
        float fWidth;
        float fHeight;
        float fPerimeter;
        fWidth = Convert.ToInt32(TextBoxWIDTH.Text);
        fHeight = Convert.ToInt32(TextBoxHEIGHT.Text);
        fPerimeter=2*(fWidth+fHeight);
        TextBoxRECTANGULAR.Text = Convert.ToString(fPerimeter);
       
    }
    protected void BTNSAVE_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        string insertSql = "INSERT INTO perimeter(width,height,perimeter) VALUES(@width,@height,@perimeter)";

using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
    SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
    myCommand.Parameters.AddWithValue("@width", TextBoxWIDTH.Text);
    myCommand.Parameters.AddWithValue("@height", TextBoxHEIGHT.Text);
            myCommand.Parameters.AddWithValue("@perimeter",TextBoxRECTANGULAR.Text);

            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }

        // "Reset" the Subject and Body TextBoxes
        TextBoxWIDTH.Text = string.Empty;
        TextBoxHEIGHT.Text= string.Empty;
        TextBoxRECTANGULAR.Text = string.Empty;
    }
}