public static void AddInvoicePurchaseOrder(InvoicePurchaseOrder purchase)
    {
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
        SqlCommand command;
        connection.Open();
        try
        {
            command = connection.CreateCommand();
            command.CommandText = "INSERT INTO UnileverInvoiceTrackingSystem.dbo.purchaseorder (invoiceno, purchaseorderno, attachment, purchaseorderdate) VALUES (@IN,@PON,@ATT,@POD);";

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

            command.Parameters.AddWithValue("PON", Convert.ToString(purchase.PurchaseOrderNo));

            command.Parameters.AddWithValue("@ATT", Convert.ToString(purchase.Attachment));

            command.Parameters.AddWithValue("@POD", Convert.ToDateTime(purchase.PurchaseOrderDate));

            command.ExecuteNonQuery();
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
        }
    }
Exemplo n.º 2
0
        protected void POEntryRecordButton_Click(object sender, EventArgs e)
        {
            var invoicepurchaseorderentry = new InvoicePurchaseOrder();

            invoicepurchaseorderentry.InvoiceNo = Convert.ToInt64(POInvoiceNoTextBox.Text);
            invoicepurchaseorderentry.PurchaseOrderNo = Convert.ToString(PONoTextBox.Text);
            invoicepurchaseorderentry.Attachment = "No";
            invoicepurchaseorderentry.PurchaseOrderDate = Convert.ToDateTime(PODateTextBox.Text);

            InvoicePurchaseOrderHandler.AddInvoicePurchaseOrder(invoicepurchaseorderentry);

            cleardata();
        }