Example #1
0
        public string Create(CustomerPopupModel model)
        {
            try
            {
                TravelaEntities db       = new TravelaEntities();
                CustomerT       customer = null;
                if (model.customerid > 0)
                {
                    customer = db.CustomerT.FirstOrDefault(f => f.customerid == model.customerid);
                }
                else
                {
                    customer = new CustomerT();
                }

                customer.customername    = model.customername;
                customer.customersurname = model.customersurname;
                customer.birthdate       = model.birthdate;
                customer.phone           = model.phone;
                customer.email           = model.email;
                customer.address         = model.address;

                if (model.customerid == 0)
                {
                    db.CustomerT.Add(customer);
                }

                return(db.SaveChanges().ToString());
            }
            catch
            {
                return("-1");
            }
        }
Example #2
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text) && string.IsNullOrEmpty(txtPassportNoForSearch.Text))
            {
                MessageBox.Show("请填写条件");
                return;
            }

            if (!string.IsNullOrEmpty(txtName.Text))
            {
                CustomerT tempObj = visaORM.CustomerT.FirstOrDefault(c => c.FName == txtName.Text || c.FNameEn == txtName.Text);
                if (tempObj != null)
                {
                    model = tempObj;
                    MainTab.DataContext = model;

                    return;
                }
            }

            if (!string.IsNullOrEmpty(txtPassportNoForSearch.Text))
            {
                CustomerT tempObj = visaORM.CustomerT.FirstOrDefault(c => c.FPassportNo == txtPassportNoForSearch.Text);
                if (tempObj != null)
                {
                    model = tempObj;
                    MainTab.DataContext = model;

                    return;
                }
            }
            MessageBox.Show("找不到对应签证");
        }
Example #3
0
        public ActionResult Create(BookingModel model)
        {
            TravelaEntities db       = new TravelaEntities();
            var             customer = new CustomerT()
            {
                customerid      = model.customerid,
                customername    = model.customername,
                customersurname = model.customersurname,
                birthdate       = model.birthdate,
                phone           = model.phone,
                email           = model.email,
                address         = model.address
            };


            var reservation = new ReservationT()
            {
                customerid        = model.customerid,
                hotelid           = model.hotelid,
                tourid            = model.tourid,
                status            = model.status = false,
                reservationnumber = model.reservationnumber = RandomGen2.Next()
            };


            db.CustomerT.Add(customer);
            db.ReservationT.Add(reservation);

            db.SaveChanges();

            return(Redirect("~/Web/Index"));
        }
Example #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            CustomerT customerT = db.CustomerT.Find(id);

            db.CustomerT.Remove(customerT);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
 public ActionResult Edit([Bind(Include = "customerid,customername,customersurname,birthdate,phone,email,address")] CustomerT customerT)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customerT).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customerT));
 }
Example #6
0
        public ActionResult Create([Bind(Include = "customerid,customername,customersurname,birthdate,phone,email,address")] CustomerT customerT)
        {
            if (ModelState.IsValid)
            {
                db.CustomerT.Add(customerT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customerT));
        }
Example #7
0
        // GET: CustomerTs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerT customerT = db.CustomerT.Find(id);

            if (customerT == null)
            {
                return(HttpNotFound());
            }
            return(View(customerT));
        }
Example #8
0
 private void CustomerAdd()
 {
     try
     {
         this.model          = new CustomerT();
         MainTab.DataContext = this.model;
         InitSelectValue();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
         Log.WriteLog.WriteErorrLog(ex);
     }
 }
Example #9
0
        public JsonResult Getir(int id)
        {
            TravelaEntities    db       = new TravelaEntities();
            CustomerT          customer = db.CustomerT.FirstOrDefault(f => f.customerid == id);
            CustomerPopupModel model    = new CustomerPopupModel();

            model.customerid      = customer.customerid;
            model.customername    = customer.customername;
            model.customersurname = customer.customersurname;
            model.birthdate       = customer.birthdate;
            model.phone           = customer.phone;
            model.email           = customer.email;
            model.address         = customer.address;
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Example #10
0
        /// <summary>
        /// 左侧表单双击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LeftGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            CustomerT custModel = LeftGrid.CurrentItem as CustomerT;

            var tempModel = visaORM.CustomerT.FirstOrDefault(c => c.FID == custModel.FID);

            if (tempModel == null)
            {
                return;
            }
            else
            {
                this.model          = tempModel;
                isCanChangeTime     = false;
                MainTab.DataContext = this.model;
            }
        }
Example #11
0
        private void LeftGrid_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
        {
            if (e.OldItem == null || e.NewItem == null)
            {
                return;
            }

            CustomerT custModel = e.NewItem as CustomerT;


            var tempModel = visaORM.CustomerT.FirstOrDefault(c => c.FID == custModel.FID);

            if (tempModel == null)
            {
                return;
            }
            else
            {
                this.model          = tempModel;
                isCanChangeTime     = false;
                MainTab.DataContext = this.model;
            }
        }
Example #12
0
        private void CustomerDel()
        {
            CustomerT delObj = visaORM.CustomerT.FirstOrDefault(c => c.FID == model.FID);

            if (delObj == null)
            {
                MessageBox.Show("该数据尚未保存,无需删除");
                return;
            }
            else
            {
                if (MessageBox.Show("是否确认删除?", "删除确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    visaORM.DeleteObject(delObj);
                    visaORM.SaveChanges();
                    customerCollection.Remove(delObj);
                    this.model = LeftGrid.SelectedItem as CustomerT;
                    if (this.model == null)
                    {
                        this.model = new CustomerT();
                    }
                }
            }
        }
Example #13
0
        private void btnAddBlackList_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (gridMain.SelectedItem == null)
                {
                    MessageBox.Show("请选择一条数据");
                    return;
                }

                if (MessageBox.Show("是否确认加入黑名单?", "确认加入黑名单", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    int      CID  = (gridMain.SelectedItem as sp_Customer_Select_ByDate_Result).FID;
                    Customer cObj = visaORM.Customer.FirstOrDefault(c => c.FID == CID);
                    if (cObj == null)
                    {
                        MessageBox.Show("找不到对应签证数据,加入黑名单失败");
                        return;
                    }

                    if (visaORM.CustomerT.FirstOrDefault(c => c.FPassportNo == cObj.FPassportNo) != null)
                    {
                        MessageBox.Show("该护照已经加入了黑名单。");
                        return;
                    }


                    CustomerT model = new CustomerT();
                    model.FCreateDate    = DateTime.Now;
                    model.FCreateUser    = MainContext.UserID;
                    model.FModifyDate    = DateTime.Now;
                    model.FModifyUser    = MainContext.UserID;
                    model.FCreateCompany = MainContext.UserCompanyName;

                    model.FName                     = cObj.FName;
                    model.FNameEn                   = cObj.FNameEn;
                    model.FPassportNo               = cObj.FPassportNo;
                    model.FBirthDay                 = cObj.FBirthDay;
                    model.FSex                      = cObj.FSex;
                    model.FBirthPlace               = cObj.FBirthPlace;
                    model.FBirthPlaceEn             = cObj.FBirthPlaceEn;
                    model.FBirthNationlity          = cObj.FBirthNationlity;
                    model.FBirthNationlityEn        = cObj.FBirthNationlityEn;
                    model.FBirthNationlityPresent   = cObj.FBirthNationlityPresent;
                    model.FBirthNationlityPresentEn = cObj.FBirthNationlityPresentEn;
                    model.FPassportType             = cObj.FPassportType;
                    model.FPassportMake             = cObj.FPassportMake;
                    model.FPassportMakeDate         = cObj.FPassportMakeDate;
                    model.FPassportValidDate        = cObj.FPassportValidDate;
                    model.FProfessionWork           = cObj.FProfessionWork;
                    model.FProfessionCompany        = cObj.FProfessionCompany;
                    model.FProfessionTele           = cObj.FProfessionTele;
                    model.FAddressNow               = cObj.FAddressNow;
                    model.FAddressTele              = cObj.FAddressTele;
                    model.FPurpose                  = cObj.FPurpose;
                    model.FSysMemo                  = cObj.FSysMemo;

                    visaORM.CustomerT.AddObject(model);

                    visaORM.SaveChanges();
                    MessageBox.Show("加入黑名单成功");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.WriteLog.WriteErorrLog(ex);
            }
        }