コード例 #1
0
ファイル: Linq_1.designer.cs プロジェクト: dhuyvaert/Excell
 partial void DeleteCustomer(Customer instance);
コード例 #2
0
ファイル: Linq_1.designer.cs プロジェクト: dhuyvaert/Excell
 partial void InsertCustomer(Customer instance);
コード例 #3
0
ファイル: Linq_1.designer.cs プロジェクト: dhuyvaert/Excell
 partial void UpdateCustomer(Customer instance);
コード例 #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int iCstId = 0;
            if (Request.QueryString["IsNew"] == "true")
            {
                Linq_1DataContext db = new Linq_1DataContext();
                Customer c = new Customer();
                c.Company = txtCompany.Text;
                c.Address = txtAddress.Text;
                c.City = txtCity.Text;
                if (txtZip.Text != "") { c.Zip = Convert.ToInt32(txtZip.Text); }
                c.FName = txtContact.Text;
                c.Phone = txtPhone.Text;
                c.Phone2 = txtPhone2.Text;
                c.Email = txtEmail.Text;

                try
                {
                    db.Customers.InsertOnSubmit(c);
                    db.SubmitChanges();
                    iCstId = c.id;

                }
                catch (Exception et)
                {
                    Shared.WriteError(et, HttpContext.Current, "btnSave_Click");
                }
                finally
                {
                    string redir = "~/ticketdetail.aspx?IsNew=true&cst=" + iCstId.ToString() ;
                    //string redir = "~/ticketdetail.aspx?IsNew=true";
                    Response.Redirect(redir);
                }

            }
            else
            {
                    int cid = Convert.ToInt32(txtId.Text);

                    Linq_1DataContext db = new Linq_1DataContext();
                    var t = (from a in db.Customers
                             where a.id == cid
                             select a).FirstOrDefault();
                    if (t != null)
                    {
                        t.Company = txtCompany.Text;
                        t.FName = txtContact.Text;
                        t.Address = txtAddress.Text;
                        t.City = txtCity.Text;
                        if (txtZip.Text != "") { t.Zip = Convert.ToInt32(txtZip.Text); }
                        t.Email = txtEmail.Text;
                        t.Phone = txtPhone.Text;
                        t.Phone2 = txtPhone2.Text;
                        try
                        {
                            db.SubmitChanges();
                            lblStatus.Text = "Customer " + cid.ToString() + " has been updated.";
                        }
                        catch (Exception et)
                        {
                            Shared.WriteError(et, HttpContext.Current, "btnSave_Click" );
                        }

                    }

            }
        }