コード例 #1
0
        public void Add(Object cm)
        {
            Club_Member clubMember = (Club_Member)cm;

            DB.Add(clubMember);
            DAL.Customer c = Change.CustomerBackendToDal(clubMember);
            sqlDB.Customers.InsertOnSubmit(c);
            sqlDB.SubmitChanges();
        }
コード例 #2
0
        public static DAL.Customer CustomerBackendToDal(Backend.Club_Member c)
        {
            DAL.Customer temp = new DAL.Customer();

            temp.dateOfBirth = c.dateOfBirth;
            temp.firstName   = c.firstName;
            temp.gender      = c.gender;
            temp.ID          = c.ID;
            temp.lastName    = c.lastName;
            temp.memberID    = c.memberID;
            temp.type        = c.type;
            return(temp);
        }
コード例 #3
0
        public ActionResult DeleteCustomer(int cust_id)
        {
            if (cust_id != 0)
            {
                System.Web.HttpContext.Current.Application.Lock();

                DAL.Customer delete = _db.Customer.Where(p => p.cust_id == cust_id).FirstOrDefault();

                _db.Customer.Remove(delete);
                _db.SaveChanges();

                System.Web.HttpContext.Current.Application.UnLock();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        //Get Customer Notification Details
        public Customer GetNotificationDetails(int orderNumber)
        {
            Customer customer = new DAL.Customer();

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@Order#", orderNumber)
            };
            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetCustomer", CommandType.StoredProcedure, parameters))
            {
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        customer.NotificationType = row["NotificationType"].ToString();
                        customer.Cellphone        = row["Cellphone"].ToString();
                        customer.Email            = row["Email"].ToString();
                    }
                }
            }
            return(customer);
        }
 /// <remarks>
 /// adds new Customer ntry to DB
 /// </remarks>
 /// <param name="companyName"></param>
 /// <param name="contactPerson"></param>
 /// <returns> customer ID as integer </returns>
 public int addNew(string companyName, string contactPerson)
 {
     _log.Trace("in addNew()");
     using (Keskus_baasEntities db = new Keskus_baasEntities())
     {
         DAL.Customer customer = new DAL.Customer
         {
             CompanyName = companyName,
             ContactPerson = contactPerson
         };
         db.Customers.Add(customer);
         try
         {
             db.SaveChanges();
             _userlog.Trace(string.Format("New customer added. ID {0}: {1}, {2}", customer.CustomertID, customer.CompanyName, customer.ContactPerson));
             return customer.CustomertID;
         }
         catch (Exception ex)
         {
             _log.Trace(string.Format("addNew() - An error occurred: '{0}'", ex));
         }
     }
     return 0;
 }
コード例 #6
0
        /// <summary>
        /// Saves the object to the db. Throws an exception if any the required values has not been set
        /// </summary>
        internal void Save(int actionPerformerId)
        {
            DAL.CustomersDataContext dc = new DAL.CustomersDataContext();
            DAL.Customer dalCustomer = null;

            if (this.Id == 0)
            {
                dalCustomer = new DAL.Customer();
                map(dc, this, dalCustomer, actionPerformerId);
                dc.Customers.InsertOnSubmit(dalCustomer);
            }
            else
            {
                dalCustomer = findRecord(dc, this.Id);
                map(dc, this, dalCustomer, actionPerformerId);
            }

            dc.SubmitChanges();
            this.Id = dalCustomer.Id;

            // save all new objects and update existing ones if modified
            foreach (var item in this.Addresses)
            {
                item.SaveDependent(dc, dalCustomer, actionPerformerId);
            }
            // delete all missing objects
            foreach (var item in Address.LoadWithCustomerId(dc, this.Id))
            {
                if (!this.Addresses.Contains(item))
                    Address.Delete(dc, item);
            }

            foreach (var item in this.Phones)
            {
                item.SaveDependent(dc, dalCustomer);
            }
            foreach (var item in Phone.LoadWithCustomerId(dc, this.Id))
            {
                if (!this.Phones.Contains(item))
                    Phone.Delete(dc, item);
            }

            foreach (var item in this.Logins)
            {
                item.SaveDependent(dc, dalCustomer);
            }
            foreach (var item in Login.LoadWithCustomerId(dc, this.Id))
            {
                if (!this.Logins.Contains(item))
                    Login.Delete(dc, item);
            }
        }
コード例 #7
0
 public Customer()
 {
     dal = new DAL.Customer();
 }
コード例 #8
0
        public ActionResult SaveCustomer(Models.CustomerModel data)
        {
            if (!ModelState.IsValid)
            {
                if (data.cust_id == 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Customer code = _db.Customer.Where(p => p.cuscode == data.cuscode).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        _db = new QSoft_WUEntities();
                        _db.Customer.Add(new DAL.Customer
                        {
                            cust_id        = data.cust_id,
                            cuscode        = data.cuscode,
                            cusname1       = data.cusname1,
                            cusname11      = data.cusname11,
                            cusname2       = data.cusname2,
                            cusname21      = data.cusname21,
                            cusaddress1    = data.cusaddress1,
                            cusaddress2    = data.cusaddress2,
                            cuszip         = data.cuszip,
                            custel         = data.custel,
                            cusfax         = data.cusfax,
                            cusmobile      = data.cusmobile,
                            datecontact    = data.datecontact,
                            dateinact      = data.dateinact,
                            status         = data.status,
                            p_id           = data.p_id,
                            t_id           = data.t_id,
                            niti           = data.niti,
                            acc_code       = data.acc_code,
                            gcusid         = data.gcusid,
                            contaddress1   = data.contaddress1,
                            contaddress2   = data.contaddress2,
                            contzip        = data.contzip,
                            notebill       = data.notebill,
                            noteth         = data.noteth,
                            noteen         = data.noteen,
                            cuszid         = data.cuszid,
                            credittermtype = data.credittermtype,
                            credittermday  = data.credittermday,
                            creditmoney    = data.creditmoney,
                            saleid         = data.saleid,
                            contname       = data.contname,
                            blacklist      = data.blacklist,
                            reason         = data.reason,
                            grade          = data.grade,
                            conname        = data.conname,
                            cusidinvoice   = data.cusidinvoice,
                            cusidbill      = data.cusidbill,
                            cusidsend      = data.cusidsend,
                            sendid         = data.sendid,
                            ncostcode      = data.ncostcode,
                            ndiscountcode  = data.ndiscountcode,
                            discountlist   = data.discountlist,
                            discountbill   = data.discountbill,
                            note1          = data.note1,
                            note2          = data.note2,
                            note3          = data.note3,
                            note4          = data.note4,
                            note5          = data.note5,
                            note6          = data.note6,
                            note7          = data.note7,
                            note8          = data.note8,
                            note9          = data.note9,
                            note10         = data.note10,
                            ccode          = data.ccode,
                            ShippingDate   = data.ShippingDate
                        });
                        _db.SaveChanges();
                        System.Web.HttpContext.Current.Application.UnLock();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            if (ModelState.IsValid)
            {
                if (data.cust_id != 0)
                {
                    _db = new QSoft_WUEntities();
                    DAL.Customer code = _db.Customer.Where(p => p.cuscode == data.cuscode && p.cust_id != data.cust_id).FirstOrDefault();
                    if (code != null)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        DAL.Customer edit = _db.Customer.Where(p => p.cust_id == data.cust_id).FirstOrDefault();

                        edit.cuscode        = data.cuscode;
                        edit.cusname1       = data.cusname1;
                        edit.cusname11      = data.cusname11;
                        edit.cusname2       = data.cusname2;
                        edit.cusname21      = data.cusname21;
                        edit.cusaddress1    = data.cusaddress1;
                        edit.cusaddress2    = data.cusaddress2;
                        edit.cuszip         = data.cuszip;
                        edit.custel         = data.custel;
                        edit.cusfax         = data.cusfax;
                        edit.cusmobile      = data.cusmobile;
                        edit.datecontact    = data.datecontact;
                        edit.dateinact      = data.dateinact;
                        edit.status         = data.status;
                        edit.p_id           = data.p_id;
                        edit.t_id           = data.t_id;
                        edit.niti           = data.niti;
                        edit.acc_code       = data.acc_code;
                        edit.gcusid         = data.gcusid;
                        edit.contaddress1   = data.contaddress1;
                        edit.contaddress2   = data.contaddress2;
                        edit.contzip        = data.contzip;
                        edit.notebill       = data.notebill;
                        edit.noteth         = data.noteth;
                        edit.noteen         = data.noteen;
                        edit.cuszid         = data.cuszid;
                        edit.credittermtype = data.credittermtype;
                        edit.credittermday  = data.credittermday;
                        edit.creditmoney    = data.creditmoney;
                        edit.saleid         = data.saleid;
                        edit.contname       = data.contname;
                        edit.blacklist      = data.blacklist;
                        edit.reason         = data.reason;
                        edit.grade          = data.grade;
                        edit.conname        = data.conname;
                        edit.cusidinvoice   = data.cusidinvoice;
                        edit.cusidbill      = data.cusidbill;
                        edit.cusidsend      = data.cusidsend;
                        edit.sendid         = data.sendid;
                        edit.ncostcode      = data.ncostcode;
                        edit.ndiscountcode  = data.ndiscountcode;
                        edit.discountlist   = data.discountlist;
                        edit.discountbill   = data.discountbill;
                        edit.note1          = data.note1;
                        edit.note2          = data.note2;
                        edit.note3          = data.note3;
                        edit.note4          = data.note4;
                        edit.note5          = data.note5;
                        edit.note6          = data.note6;
                        edit.note7          = data.note7;
                        edit.note8          = data.note8;
                        edit.note9          = data.note9;
                        edit.note10         = data.note10;
                        edit.ccode          = data.ccode;
                        edit.ShippingDate   = data.ShippingDate;
                        _db.SaveChanges();
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }

            return(View(data));
        }