public static void AddGRNDetail(GRNDetail gd)
    {
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
        SqlCommand command;
        connection.Open();
        try
        {
            command = connection.CreateCommand();

            command.CommandText = "INSERT INTO UnileverInvoiceTrackingSystem.dbo.grndetails (grnno, grntype, grndate, grnamount, invoiceno) VALUES (@GN,@GT,@GD,@GA,@IN);";

            command.Parameters.AddWithValue("@GN", Convert.ToString(gd.GRNNO));

            command.Parameters.AddWithValue("@GT", gd.GRNT);

            command.Parameters.AddWithValue("@GD", Convert.ToDateTime(gd.GRND));

            command.Parameters.AddWithValue("@GA", Convert.ToDecimal(gd.GRNA));

            command.Parameters.AddWithValue("IN", Convert.ToInt64(gd.InvoiceNo));

            command.ExecuteNonQuery();
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
        }
    }
        protected void GRNRecordEntryButton_Click(object sender, EventArgs e)
        {
            var grnentry = new GRNDetail();

            grnentry.GRNNO = Convert.ToString(GRNNoTextBox.Text);
            grnentry.GRNT = Convert.ToString(GRNTypeDropDownList.SelectedValue);
            grnentry.GRNA = Convert.ToDecimal(GRNAmountTextBox.Text);
            grnentry.GRND = Convert.ToDateTime(GRNDateTextBox.Text);
            grnentry.InvoiceNo = Convert.ToInt64(GRNInvoiceNoTextBox.Text);

            GRNDetailHandler.AddGRNDetail(grnentry);

            cleardata();
        }