示例#1
0
    protected void btnAddInvoice_Click(object sender, EventArgs e)
    {
        InvoicingDataContext db = new InvoicingDataContext();

        InvoiceDetail invoice = new InvoiceDetail();
        invoice.invoice_number = this.txtInvoiceRef.Text;
        invoice.personal_details = this.ddlPersonalDetails.SelectedIndex + 1;
        invoice.client_details = this.ddlClient.SelectedIndex + 1;
        invoice.bank_details = this.ddlBank.SelectedIndex + 1;
        invoice.time_worked = Convert.ToInt32(this.txtTimeWorked.Text);
        invoice.rate = Convert.ToInt32(this.txtRate.Text);
        invoice.date_from = Convert.ToDateTime(this.txtDateFrom.Text);
        invoice.date_to = Convert.ToDateTime(this.txtDateTo.Text);

        db.InvoiceDetails.InsertOnSubmit(invoice);
        try
        {
            db.SubmitChanges();
        }
        catch
        {
            Response.Write("Couldn't add invoice");
        }
        finally
        {
            Response.Write("success");
        }
    }
示例#2
0
    protected void btnAddClient_Click(object sender, EventArgs e)
    {
        InvoicingDataContext db = new InvoicingDataContext();
        ClientDetail client = new ClientDetail
        {
            name = this.txtName.Text,
            email = this.txtEmail.Text,
            telephone = Convert.ToInt32(this.txtTelephone.Text),
            address_line1 = this.txtAddress1.Text,
            address_line2 = this.txtAddress2.Text,
            city = this.txtCity.Text,
            county = this.txtCounty.Text,
            post_code = this.txtPostCode.Text
        };

        db.ClientDetails.InsertOnSubmit(client);
        db.SubmitChanges();
    }