コード例 #1
0
    // save a single customer and related info
    public bool updateCustomer(string customerID, int personID, int addressID,
                               string fName, string lName, string status, string home, string work,
                               string mobile, string email1, string email2, string bldg, string unit, string street, string city,
                               string postal, string houseType, string area)
    {
        Customer c  = db.Customers.Where(i => i.custID == customerID).FirstOrDefault();
        Person   p  = db.People.Where(x => x.Id == personID).FirstOrDefault();
        Address  a  = db.Addresses.Where(s => s.Id == addressID).FirstOrDefault();
        Property pr = db.Properties.Where(px => px.Address_Id == a.Id).FirstOrDefault();

        c.status = status;
        db.SaveChanges();

        p.fname       = fName;
        p.lname       = lName;
        p.email1      = email1;
        p.email2      = email2;
        p.homePhone   = home;
        p.workPhone   = work;
        p.mobilePhone = mobile;
        db.SaveChanges();

        if (bldg != "" && bldg != null)
        {
            a.bldg = Convert.ToInt32(bldg);
        }
        else
        {
            a.bldg = null;
        }

        if (unit != "" && unit != null)
        {
            a.unit = Convert.ToInt32(unit);
        }
        else
        {
            a.unit = null;
        }
        a.street = street;
        a.city   = city;
        a.postal = postal.ToUpper();
        db.SaveChanges();

        pr.HouseType_Id = Convert.ToInt32(houseType);
        pr.Area_Id      = Convert.ToInt32(area);
        db.SaveChanges();

        if (c != null && p != null && a != null)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #2
0
    public bool updateEmployee(string EmployeeID, int AddressID, string FirstName, string LastName, string Status,
                               string HomePhone, string WorkPhone, string MobilePhone, string Email1, string Email2, string Bldg, string Unit, string Street, string City,
                               string Postal)
    {
        Employee c = db.Employees.Where(i => i.empID == EmployeeID).FirstOrDefault();
        Address  a = db.Addresses.Where(sx => sx.Id == AddressID).FirstOrDefault();

        c.status      = Status;
        c.fname       = FirstName;
        c.lname       = LastName;
        c.email1      = Email1;
        c.email2      = Email2;
        c.homePhone   = HomePhone;
        c.workPhone   = WorkPhone;
        c.mobilePhone = MobilePhone;
        db.SaveChanges();

        if (Bldg != "" && Bldg != null)
        {
            a.bldg = Convert.ToInt32(Bldg);
        }
        else
        {
            a.bldg = null;
        }

        if (Unit != "" && Unit != null)
        {
            a.unit = Convert.ToInt32(Unit);
        }
        else
        {
            a.unit = null;
        }
        a.street = Street;
        a.city   = City;
        a.postal = Postal.ToUpper();
        db.SaveChanges();

        db.SaveChanges();

        if (c != null && a != null)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #3
0
    //=======================================================================================
    // CREATES
    //=======================================================================================

    // create an invoice attaching a quote
    public Invoice createInvoice(int qid, int cid, string quote)
    {
        Invoice i = new Invoice();

        if (i != null)
        {
            // need name, customer, etc
            i.Quote_Id      = qid;
            i.Customer_Id   = cid;
            i.dateCreated   = DateTime.Now;
            i.InvoiceID     = quote;
            i.paymentStatus = "Not paid";
            i.jobStatus     = "Set";
            db.Invoices.AddObject(i);
            db.SaveChanges();
            return(i);
        }
        else
        {
            return(null);
        }
    }
コード例 #4
0
    public Area addNewArea(string from, string to, Single mult)
    {
        Area tmp = new Area();

        // check if all data is correct
        if (from != null && from != "" &&
            to != null && to != "" &&
            mult > 0 && Convert.ToInt32(to) > Convert.ToInt32(from))
        {
            tmp.fromMin = from;
            tmp.toMax   = to;
            tmp.areaVal = mult;
            db.Areas.AddObject(tmp);
        }
        else
        {
            tmp = null;
        }


        db.SaveChanges();

        return(tmp);
    }