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

            command.CommandText = "INSERT INTO UnileverInvoiceTrackingSystem.dbo.shortagedetails (invoiceno, shortagedetails) VALUES (@IN,@SD);";

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

            command.Parameters.AddWithValue("@SD", sd.SD);

            command.ExecuteNonQuery();
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
        }
    }
예제 #2
0
        protected void InvoiceRecordButton_Click(object sender, EventArgs e)
        {
            DateTime duedate;
            duedate = Convert.ToDateTime(InvoiceDateTextBox.Text);
            duedate = duedate.AddDays(40);

            InvoiceDetail invoiceentry = new InvoiceDetail();

            InvoicePayment invoicepayment = new InvoicePayment();

            ShortageDetails shortagedetail = new ShortageDetails();

            invoiceentry.InvoiceNo = Convert.ToInt64(InvoiceNoTextBox.Text);
            invoiceentry.InvoiceTerritory = getterritory();
            invoiceentry.InvoiceRegion = InvoiceRegionDropDownList.SelectedValue;
            invoiceentry.InvoiceDate = Convert.ToDateTime(InvoiceDateTextBox.Text).Date;
            invoiceentry.InvoiceDueDate = duedate.Date;
            invoiceentry.InvoiceAging = Convert.ToInt32((DateTime.Now.Date - Convert.ToDateTime(InvoiceDateTextBox.Text).Date).TotalDays);
            invoiceentry.NPA = Convert.ToDecimal(NetAmountTextBox.Text);
            invoiceentry.SC = ShortageCommentsDropDownList.SelectedValue;

            InvoiceDetailHandler.AddInvoiceDetail(invoiceentry);

            invoicepayment.InvoiceNo = Convert.ToInt64(InvoiceNoTextBox.Text);
            invoicepayment.PaymentStatus = "Non-Paid";
            invoicepayment.AmountReceived = Convert.ToDecimal("0.00");
            invoicepayment.Balance = Convert.ToDecimal("0.00");
            invoicepayment.PaymentRemarks = "Under Progress";

            InvoicePaymentHandler.AddInvoicePayment(invoicepayment);

            shortagedetail.InvoiceNo = Convert.ToInt64(InvoiceNoTextBox.Text);
            shortagedetail.SD = ShortageDetailsTextBox.Text;

            ShortageDetailHandler.AddShortageDetail(shortagedetail);

            cleardata();
        }