//
        // GET: /CrmInterfacing/
        public ActionResult CRM_Customer_Booking(
            string customer_code,
            string tel,
            string contact,
            string email,
            string remark,
            string bookings
            )
        {
            if (!string.IsNullOrWhiteSpace(customer_code))
            {
                db _db = new db();
                var customer = (from c in _db.recsys_customers
                                where c.status == 1 && c.customer_code.Contains(customer_code)
                                select c).FirstOrDefault();
                if (customer != null)
                {
                    recsys_relate_customers customer_data = new recsys_relate_customers()
                    {
                        customer_id = customer.id,
                        name = customer.name,
                        customer_code = customer.customer_code,
                        prefix = customer.prefix,
                        code = customer.code,
                        manual_input_code = customer.manual_input_code,
                        contact = contact,
                        relate_type = (int)CustomerDataRelateType.Enquery,
                        tel2 = tel,
                        email = email
                    };

                    _db.recsys_relate_customers.AddObject(customer_data);

                    _db.SaveChanges();

                    _db.Refresh(System.Data.Objects.RefreshMode.StoreWins, customer_data);

                    if (customer_data.id != 0)
                    {
                        recsys_enquery enquery = new recsys_enquery()
                        {
                            create_date = DateTime.Now,
                            customer_id = customer_data.id,
                            last_update = DateTime.Now,
                            remark = remark,
                            sBookingInformation = bookings,
                            status = (int) RecordStatus.Active
                        };

                        _db.recsys_enquery.AddObject(enquery);

                        _db.SaveChanges();

                        return Content("true");
                    }
                }
            }
            return Content("false");
        }
        private ActionResult Add(EnqueryGridRecordBase data, int? masterCustomerID, int Status2)
        {
            bool isSuccess = false;

            Member member = new Member("users");
            recsys_customers masterCustomer = null;
            recsys_relate_customers newCustomerData;
            recsys_enquery newRecord;

            try
            {
                if (masterCustomerID.HasValue)
                    masterCustomer = this._db.recsys_customers.FirstOrDefault(theCustomer => theCustomer.id == masterCustomerID);

                newCustomerData = new recsys_relate_customers()
                {
                    customer_id = masterCustomerID.HasValue ? masterCustomerID.Value : -1,
                    name = masterCustomer == null ? null : masterCustomer.name,
                    manual_input_code = masterCustomer == null ? null : masterCustomer.manual_input_code,
                    code = masterCustomer == null ? null : masterCustomer.code,
                    prefix = masterCustomer == null ? null : masterCustomer.prefix,
                    contact = data.Contact,
                    customer_code = masterCustomer == null ? null : masterCustomer.customer_code,
                    type = masterCustomer == null ? (byte?) null : masterCustomer.type,
                    tel2 = data.Tel,
                    email = data.EMail,
                    relate_type = (int)CustomerDataRelateType.Enquery
                };

                this._db.recsys_relate_customers.AddObject(newCustomerData);
                this._db.SaveChanges();
                this._db.Refresh(System.Data.Objects.RefreshMode.StoreWins, newCustomerData);

                if (newCustomerData.id <= 0)
                    return Json(false, JsonRequestBehavior.AllowGet);

                newRecord = new recsys_enquery()
                {
                    create_date = DateTime.Now,
                    customer_id = newCustomerData.id,
                    last_update = DateTime.Now,
                    remark = data.Remark,
                    sBookingInformation = data.BookingInformation,
                    status = (byte) Status2,
                    update_user_id = (int)member.infoBySession("id")
                };

                this._db.recsys_enquery.AddObject(newRecord);

                this._db.SaveChanges();

                isSuccess = true;
            }
            catch (OptimisticConcurrencyException)
            {
                //# log down
            }

            return Json(isSuccess, JsonRequestBehavior.AllowGet);
        }
        public ActionResult CRM_Customer_Enquery(
            string tel,
            string contact,
            string email,
            string remark,
            string address,
            string company_name
            )
        {
            db _db = new db();
            recsys_relate_customers customer_data = new recsys_relate_customers()
            {
                customer_id = -1,
                contact = contact,
                relate_type = (int)CustomerDataRelateType.Enquery,
                tel2 = tel,
                email = email,
                address2 = address
            };

            _db.recsys_relate_customers.AddObject(customer_data);

            _db.SaveChanges();

            _db.Refresh(System.Data.Objects.RefreshMode.StoreWins, customer_data);

            if (customer_data.id != 0)
            {
                recsys_enquery enquery = new recsys_enquery()
                {
                    create_date = DateTime.Now,
                    customer_id = customer_data.id,
                    last_update = DateTime.Now,
                    remark = (string.IsNullOrEmpty(company_name) ? string.Empty : "[公司名稱] " + company_name + "\r\n") + remark,
                    status = (int)RecordStatus.Active
                };

                _db.recsys_enquery.AddObject(enquery);

                _db.SaveChanges();

                return Content("true");
            }
            return Content("false");
        }
Exemple #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the recsys_enquery EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTorecsys_enquery(recsys_enquery recsys_enquery)
 {
     base.AddObject("recsys_enquery", recsys_enquery);
 }
Exemple #5
0
 /// <summary>
 /// Create a new recsys_enquery object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="user_id">Initial value of the user_id property.</param>
 /// <param name="customer_id">Initial value of the customer_id property.</param>
 /// <param name="status">Initial value of the status property.</param>
 /// <param name="create_date">Initial value of the create_date property.</param>
 /// <param name="update_user_id">Initial value of the update_user_id property.</param>
 public static recsys_enquery Createrecsys_enquery(global::System.Int32 id, global::System.Int32 user_id, global::System.Int32 customer_id, global::System.Byte status, global::System.DateTime create_date, global::System.Int32 update_user_id)
 {
     recsys_enquery recsys_enquery = new recsys_enquery();
     recsys_enquery.id = id;
     recsys_enquery.user_id = user_id;
     recsys_enquery.customer_id = customer_id;
     recsys_enquery.status = status;
     recsys_enquery.create_date = create_date;
     recsys_enquery.update_user_id = update_user_id;
     return recsys_enquery;
 }