Beispiel #1
0
        protected override void FormLoad()
        {
            base.FormLoad();
            var client   = new CRMServiceClient();
            var stypelst = client.getSuptypeLst();

            foreach (var suptype in stypelst)
            {
                cmb_stype.Properties.Items.Add(suptype.typename);
            }
            if (this.formmode == frmmodetype.edit)
            {
                m_supplier = client.getSupplierbyId(m_supplierid);
                SetData();
            }
            else if (formmode == frmmodetype.delete)
            {
                m_supplier = client.getSupplierbyId(m_supplierid);
                SetData();
                readonlytxtbox(this.Controls, true);
            }
            var contactlst = client.getSupplierContacts(m_supplierid);

            this.gcContact.DataSource = contactlst;
        }
Beispiel #2
0
        protected override void AddObject()
        {
            T_Suppliers newsupplier = new T_Suppliers();

            newsupplier.accountname   = txt_accountname.Text;
            newsupplier.accountno     = txt_accountno.Text;
            newsupplier.address       = txt_address.Text;
            newsupplier.bank          = txt_bank.Text;
            newsupplier.city          = txt_city.Text;
            newsupplier.country       = txt_country.Text;
            newsupplier.email         = txt_email.Text;
            newsupplier.fax           = txt_fax.Text;
            newsupplier.legalperson   = txt_legalman.Text;
            newsupplier.telphone      = txt_phone.Text;
            newsupplier.postcode      = txt_postcode.Text;
            newsupplier.province      = txt_province.Text;
            newsupplier.remarks       = txt_remarks.Text;
            newsupplier.businessscope = txt_scope.Text;
            newsupplier.simplename    = txt_simplename.Text;
            newsupplier.suppliername  = txt_splname.Text;
            newsupplier.supplierno    = txt_splno.Text;
            newsupplier.taxcode       = txt_taxno.Text;
            newsupplier.website       = txt_website.Text;
            newsupplier.suppliertype  = cmb_stype.SelectedText;
            var client = new CRMServiceClient();

            client.addNewSupplier(newsupplier);
            saveContact();
            base.AddObject();
        }
Beispiel #3
0
 protected override void AddObject()
 {
     T_Suppliers newsupplier = new T_Suppliers();
     newsupplier.accountname = txt_accountname.Text;
     newsupplier.accountno = txt_accountno.Text;
     newsupplier.address = txt_address.Text;
     newsupplier.bank = txt_bank.Text;
     newsupplier.city = txt_city.Text;
     newsupplier.country = txt_country.Text;
     newsupplier.email = txt_email.Text;
     newsupplier.fax = txt_fax.Text;
     newsupplier.legalperson = txt_legalman.Text;
     newsupplier.telphone = txt_phone.Text;
     newsupplier.postcode = txt_postcode.Text;
     newsupplier.province = txt_province.Text;
     newsupplier.remarks = txt_remarks.Text;
     newsupplier.businessscope = txt_scope.Text;
     newsupplier.simplename = txt_simplename.Text;
     newsupplier.suppliername = txt_splname.Text;
     newsupplier.supplierno = txt_splno.Text;
     newsupplier.taxcode = txt_taxno.Text;
     newsupplier.website = txt_website.Text;
     newsupplier.suppliertype = cmb_stype.SelectedText;
     var client = new CRMServiceClient();
     client.addNewSupplier(newsupplier);
     base.AddObject();
 }
Beispiel #4
0
 internal void updateSupplier(T_Suppliers supplier)
 {
     using (MEMSContext db = new MEMSContext())
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #5
0
 internal void addNewSupplier(T_Suppliers newsupplier)
 {
     using (MEMSContext db = new MEMSContext())
     {
         db.T_Suppliers.Add(newsupplier);
         db.SaveChanges();
     }
 }
Beispiel #6
0
 internal void delSupplier(T_Suppliers supplier)
 {
     using (MEMSContext db = new MEMSContext())
     {
         //db.T_Customer.Remove(customer);
         var entityentry = db.Entry(supplier);
         entityentry.State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Beispiel #7
0
 public void EditSupplier(T_Suppliers supplier)
 {
     try
     {
         sh = new SupplierHelper();
         sh.updateSupplier(supplier);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #8
0
 public void DeleteSupplier(T_Suppliers supplier)
 {
     try
     {
         sh = new SupplierHelper();
         sh.delSupplier(supplier);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #9
0
 public void addNewSupplier(T_Suppliers newsupplier)
 {
     try
     {
         sh = new SupplierHelper();
         sh.addNewSupplier(newsupplier);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #10
0
        public ActionResult ViewSupplierEdit(int ID)
        {
            T_Suppliers model = db.T_Suppliers.Find(ID);

            if (model != null)
            {
                return(View(model));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Beispiel #11
0
 public JsonResult SupplierAddSave(T_Suppliers model)
 {
     model.Isdelete = "0";
     db.T_Suppliers.Add(model);
     try
     {
         db.SaveChanges();
         return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
     }
     catch (DbEntityValidationException ex)
     {
         return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #12
0
        public JsonResult SupplierDelete(int ID)
        {
            T_Suppliers editModel = db.T_Suppliers.Find(ID);

            editModel.Isdelete = "1";
            db.Entry <T_Suppliers>(editModel).State = System.Data.Entity.EntityState.Modified;
            try
            {
                db.SaveChanges();
                return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
            }
            catch (DbEntityValidationException ex)
            {
                return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #13
0
        public JsonResult SupplierEditSave(T_Suppliers model)
        {
            T_Suppliers editModel = db.T_Suppliers.Find(model.ID);

            editModel.SuppliersName                 = model.SuppliersName;
            editModel.ContactName                   = model.ContactName;
            editModel.ContactiTelephone             = model.ContactiTelephone;
            db.Entry <T_Suppliers>(editModel).State = System.Data.Entity.EntityState.Modified;
            try
            {
                db.SaveChanges();
                return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
            }
            catch (DbEntityValidationException ex)
            {
                return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #14
0
        public ActionResult Modify(Supplier param)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_SUCCESS,
                Message = SystemConst.MSG_ERR_UNKNOWN
            };

            using (var db = new TravelEntities())
            {
                T_Suppliers selectSupplier = db.T_Suppliers.FirstOrDefault(a => a.SupplierID == param.SupplierID);
                selectSupplier.SupplierName = param.SupplierName;
                selectSupplier.Contact      = param.Contact;
                db.T_Suppliers.Attach(selectSupplier);
                db.Entry(selectSupplier).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return(Content(AppUtils.JsonSerializer(result)));
        }
Beispiel #15
0
 protected override void FormLoad()
 {
     base.FormLoad();
     var client = new CRMServiceClient();
     var stypelst = client.getSuptypeLst();
     foreach (var suptype in stypelst)
     {
         cmb_stype.Properties.Items.Add(suptype.typename);
     }
     if (this.formmode == frmmodetype.edit)
     {
         m_supplier = client.getSupplierbyId(m_supplierid);
         SetData();
     }
     else if (formmode == frmmodetype.delete)
     {
         m_supplier = client.getSupplierbyId(m_supplierid);
         SetData();
         enabletxtbox(this.Controls);
     }
     var contactlst = new List<T_Suppliers_contacts>(client.getSupplierContacts(m_supplierid));
     this.gcContact.DataSource = contactlst;
 }
Beispiel #16
0
        public ActionResult Add(SupplierPara param)
        {
            WebResult result = new WebResult
            {
                Code    = SystemConst.MSG_ERR_UNKNOWN,
                Message = String.Empty
            };

            try
            {
                using (var db = new TravelEntities())
                {
                    var supplier = new T_Suppliers
                    {
                        SupplierName = param.supplier.SupplierName,
                        Contact      = param.supplier.Contact,
                        HasHotel     = SystemConst.TRUE,
                        HasService   = SystemConst.TRUE
                    };
                    db.T_Suppliers.Add(supplier);
                    db.SaveChanges();

                    bool needSave = false;
                    if (param.travelProjects != null)
                    {
                        for (var i = 0; i < param.travelProjects.Count; i++)
                        {
                            TravelProjectDto travelProjectDto = param.travelProjects[i];
                            var travelProject = new T_TravelProjects
                            {
                                ProjectName   = travelProjectDto.ProjectName,
                                AdultFee      = travelProjectDto.AdultFee,
                                ChildFee      = travelProjectDto.ChildFee,
                                SupplierID    = supplier.SupplierID,
                                AgentAdultFee = travelProjectDto.AgentAdultFee,
                                AgentChildFee = travelProjectDto.AgentChildFee,
                                CoverPic      = travelProjectDto.CoverPic,
                                Remark        = travelProjectDto.Remark,
                                Description   = travelProjectDto.Description,
                                ProjectTypeID = travelProjectDto.ProjectTypeID
                            };
                            db.T_TravelProjects.Add(travelProject);
                            needSave = true;
                        }
                    }

                    if (param.hotels != null)
                    {
                        for (var i = 0; i < param.hotels.Count; i++)
                        {
                            HotelDto hotelDto = param.hotels[i];
                            var      hotel    = new T_LiveProjects
                            {
                                HouseName   = hotelDto.HouseName,
                                Fee         = hotelDto.Fee,
                                SupplierID  = supplier.SupplierID,
                                AgentFee    = hotelDto.AgentFee,
                                CoverPic    = hotelDto.CoverPic,
                                Description = hotelDto.Description,
                                Remark      = hotelDto.Remark,
                                Pics        = hotelDto.Pics,
                                Location    = hotelDto.Location,
                                RoomCount   = hotelDto.RoomCount
                            };
                            db.T_LiveProjects.Add(hotel);
                            needSave = true;
                        }
                    }

                    if (needSave)
                    {
                        db.SaveChanges();
                    }

                    result.Code = SystemConst.MSG_SUCCESS;
                    return(Content(AppUtils.JsonSerializer(result)));
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                return(Content(AppUtils.JsonSerializer(result)));
            }
        }