Exemple #1
0
 private void SetData(T_Customer customer)
 {
     txt_cpno.Text                 = customer.customerno;
     txt_copname.Text              = customer.customername;
     txt_copsname.Text             = customer.simplename;
     txt_country.Text              = customer.country;
     txt_website.Text              = customer.website;
     txt_address.Text              = customer.companyaddress;
     txt_city.Text                 = customer.city;
     txt_customerdesc.Text         = customer.customerdesc;
     txt_email.Text                = customer.email;
     txt_cw_accountname.Text       = customer.accountname;
     txt_cw_accountno.Text         = customer.accountno;
     txt_cw_address.Text           = customer.invoiceaddress;
     txt_cw_bank.Text              = customer.bank;
     txt_cw_taxcode.Text           = customer.taxcode;
     txt_fax.Text                  = customer.fax;
     txt_postcode.Text             = customer.postcode;
     txt_productinfo.Text          = customer.productinfo;
     txt_phone.Text                = customer.phone;
     txt_province.Text             = customer.province;
     txt_remark.Text               = customer.remarks;
     cmb_companytype.SelectedText  = customer.companytype;
     cmb_customertype.SelectedText = customer.customertype;
     cmb_profession.SelectedText   = customer.profession;
 }
Exemple #2
0
        protected override void AddObject()
        {
            T_Customer newcustomer = new T_Customer();

            newcustomer.customerno     = txt_cpno.Text;
            newcustomer.customername   = txt_copname.Text;
            newcustomer.simplename     = txt_copsname.Text;
            newcustomer.country        = txt_country.Text;
            newcustomer.website        = txt_website.Text;
            newcustomer.companyaddress = txt_address.Text;
            newcustomer.city           = txt_city.Text;
            newcustomer.customerdesc   = txt_customerdesc.Text;
            newcustomer.email          = txt_email.Text;
            newcustomer.accountname    = txt_cw_accountname.Text;
            newcustomer.accountno      = txt_cw_accountno.Text;
            newcustomer.invoiceaddress = txt_cw_address.Text;
            newcustomer.bank           = txt_cw_bank.Text;
            newcustomer.taxcode        = txt_cw_taxcode.Text;
            newcustomer.fax            = txt_fax.Text;
            newcustomer.postcode       = txt_postcode.Text;
            newcustomer.productinfo    = txt_productinfo.Text;
            newcustomer.phone          = txt_phone.Text;
            newcustomer.province       = txt_province.Text;
            newcustomer.remarks        = txt_remark.Text;
            newcustomer.customertype   = cmb_customertype.SelectedText;
            newcustomer.companytype    = cmb_companytype.SelectedText;
            newcustomer.profession     = cmb_profession.SelectedText;
            var client = new CRMServiceClient();

            client.AddNewCustomer(newcustomer);
            saveAddress();
            saveContact();
            base.AddObject();
        }
Exemple #3
0
 bool checkPermis(T_Customer obj, int actionUser, bool isOwner)
 {
     if (isOwner)
     {
         return(true);
     }
     return(obj.CreatedUser == actionUser);
 }
Exemple #4
0
 internal void addNewCustomer(T_Customer newcustomer)
 {
     using (MEMSContext db = new MEMSContext())
     {
         db.T_Customer.Add(newcustomer);
         db.SaveChanges();
     }
 }
Exemple #5
0
 internal void editCustomer(T_Customer customer)
 {
     using (MEMSContext db = new MEMSContext())
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemple #6
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            T_Customer t_Customer = await db.T_Customer.FindAsync(id);

            db.T_Customer.Remove(t_Customer);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public async Task <object> GetCustomer(T_Customer model)
        {
            object o = await T_Customer_BLL.GetCustomer(model.Cid);

            return(Ok(new
            {
                statusCode = 200,
                result = o
            }));
        }
Exemple #8
0
 internal void delCustomer(T_Customer customer)
 {
     using (MEMSContext db = new MEMSContext())
     {
         //db.T_Customer.Remove(customer);
         var entityentry = db.Entry(customer);
         entityentry.State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Exemple #9
0
        public async Task <ActionResult> Edit([Bind(Include = "CustomerID,DeptId,Name,Address,Phone,DueAdvance,IsRemoved,IUser,EUser,IDate,EDate,DueLimit,BrId")] T_Customer t_Customer)
        {
            if (ModelState.IsValid)
            {
                db.Entry(t_Customer).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(t_Customer));
        }
Exemple #10
0
 public void EditCustomer(T_Customer customer)
 {
     try
     {
         ch = new CustomerHelper();
         ch.editCustomer(customer);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #11
0
 public void DeleteCustomer(T_Customer customer)
 {
     try
     {
         ch = new CustomerHelper();
         ch.delCustomer(customer);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #12
0
 public void AddNewCustomer(T_Customer newcustomer)
 {
     try
     {
         ch = new CustomerHelper();
         ch.addNewCustomer(newcustomer);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #13
0
        // GET: T_Customer/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_Customer t_Customer = await db.T_Customer.FindAsync(id);

            if (t_Customer == null)
            {
                return(HttpNotFound());
            }
            return(View(t_Customer));
        }
Exemple #14
0
        public async Task <object> Save(T_Customer model)
        {
            var cname   = model.CName;
            var contact = model.Contact;

            using (db = new KBLDataContext())
            {
                var exist = await(from c in db.Customers where c.Cid == model.Cid select c).FirstOrDefaultAsync();
                if (exist == null)
                {
                    db.Customers.Add(model);
                    int effects = await db.SaveChangesAsync();

                    return(new
                    {
                        effects = effects,
                        model = model
                    });
                }
                else
                {
                    //UpdateModel();
                    exist.Dietitian       = model.Dietitian;
                    exist.CName           = model.CName;
                    exist.CustomerNo      = model.CustomerNo;
                    exist.Age             = model.Age;
                    exist.CategoryID      = model.CategoryID;
                    exist.Addr            = model.Addr;
                    exist.Weight          = model.Weight;
                    exist.Height          = model.Height;
                    exist.Gender          = model.Gender;
                    exist.Contact         = model.Contact;
                    exist.CardType        = model.CardType;
                    exist.Married         = model.Married;
                    exist.Address         = model.Address;
                    exist.Remark          = model.Remark;
                    db.Entry(exist).State = EntityState.Modified;
                    int effects = await db.SaveChangesAsync();

                    return(new
                    {
                        effects = effects
                    });
                }
            }
        }
Exemple #15
0
        public async Task <object> Register(T_JSON model)
        {
            T_Customer customer = new T_Customer();
            object     effects  = 0;

            if (model.Input0 != null)
            {
                string s = string.Empty;
                s        = POSTJson.ResolveTJSON(model);
                customer = JsonConvert.DeserializeObject <T_Customer>(s);
                effects  = await T_Customer_BLL.SaveCustomer(customer);
            }
            return(Ok(new
            {
                statusCode = 200,
                result = effects
            }));
        }
Exemple #16
0
        private bool CheckExists(string code, int?id, int?companyId)
        {
            try
            {
                T_Customer obj = null;
                obj = db.T_Customer.FirstOrDefault(x => !x.IsDeleted && x.CompanyId == companyId && x.Name.Trim().ToUpper().Equals(code) && x.Id != id);

                if (obj == null)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #17
0
        protected override void FormLoad()
        {
            base.FormLoad();
            var client = new CRMServiceClient();

            if (this.formmode == frmmodetype.edit)
            {
                m_customer = client.getCustomerbyid(m_cid);
                SetData(m_customer);
            }
            else if (formmode == frmmodetype.delete)
            {
                m_customer = client.getCustomerbyid(m_cid);
                SetData(m_customer);
                readonlytxtbox(this.Controls, true);
            }
            var comtypelst = client.getCpytypeList();

            foreach (var comtype in comtypelst)
            {
                this.cmb_companytype.Properties.Items.Add(comtype.typename);
            }
            var custypelst = client.getCtmtypeList();

            foreach (var custype in custypelst)
            {
                this.cmb_customertype.Properties.Items.Add(custype.typename);
            }
            var proflst = client.getProfList();

            foreach (var prof in proflst)
            {
                this.cmb_profession.Properties.Items.Add(prof.professionname);
            }
            List <T_Customer_address> addresslst = client.getCustomerAddressList(m_cid);

            this.gcaddress.DataSource = addresslst;
            List <T_Customer_contacts> contactlst = client.getCustomerContactList(m_cid);

            this.gccontacts.DataSource = contactlst;

            //this.btn_addressdel.Visible = false;
            //this.btn_contactdel.Visible = false;
        }
Exemple #18
0
        protected override void FormLoad()
        {
            base.FormLoad();
            var client = new CRMServiceClient();
            if (this.formmode == frmmodetype.edit)
            {
                m_customer = client.getCustomerbyid(m_cid);
                SetData(m_customer);
            }
            else if (formmode == frmmodetype.delete)
            {
                m_customer = client.getCustomerbyid(m_cid);
                SetData(m_customer);
                enabletxtbox(this.Controls);
            }
            var comtypelst = client.getCpytypeList();
            foreach (var comtype in comtypelst)
            {
                this.cmb_companytype.Properties.Items.Add(comtype.typename);
            }
            var custypelst = client.getCtmtypeList();
            foreach (var custype in custypelst)
            {
                this.cmb_customertype.Properties.Items.Add(custype.typename);
            }
            var proflst = client.getProfList();
            foreach (var prof in proflst)
            {
                this.cmb_profession.Properties.Items.Add(prof.professionname);
            }
            List<T_Customer_address> addresslst = new List<T_Customer_address>(client.getCustomerAddressList(m_cid));
            this.gcaddress.DataSource = addresslst;
            List<T_Customer_contacts> contactlst = new List<T_Customer_contacts>(client.getCustomerContactList(m_cid));
            this.gccontacts.DataSource = contactlst;

            //this.btn_addressdel.Visible = false;
            //this.btn_contactdel.Visible = false;
        }
Exemple #19
0
 protected override void AddObject()
 {
     T_Customer newcustomer = new T_Customer();
     newcustomer.customerno = txt_cpno.Text;
     newcustomer.customername = txt_copname.Text;
     newcustomer.simplename = txt_copsname.Text;
     newcustomer.country = txt_country.Text;
     newcustomer.website = txt_website.Text;
     newcustomer.companyaddress = txt_address.Text;
     newcustomer.city = txt_city.Text;
     newcustomer.customerdesc = txt_customerdesc.Text;
     newcustomer.email = txt_email.Text;
     newcustomer.accountname = txt_cw_accountname.Text;
     newcustomer.accountno = txt_cw_accountno.Text;
     newcustomer.invoiceaddress = txt_cw_address.Text;
     newcustomer.bank = txt_cw_bank.Text;
     newcustomer.taxcode = txt_cw_taxcode.Text;
     newcustomer.fax = txt_fax.Text;
     newcustomer.postcode = txt_postcode.Text;
     newcustomer.productinfo = txt_productinfo.Text;
     newcustomer.phone = txt_phone.Text;
     newcustomer.province = txt_province.Text;
     newcustomer.remarks = txt_remark.Text;
     newcustomer.customertype = cmb_customertype.SelectedText;
     newcustomer.companytype = cmb_companytype.SelectedText;
     newcustomer.profession = cmb_profession.SelectedText;
     var client = new CRMServiceClient();
     client.AddNewCustomer(newcustomer);
     base.AddObject();
 }
Exemple #20
0
 private void SetData(T_Customer customer)
 {
     txt_cpno.Text = customer.customerno;
     txt_copname.Text = customer.customername;
     txt_copsname.Text = customer.simplename;
     txt_country.Text = customer.country;
     txt_website.Text = customer.website;
     txt_address.Text = customer.companyaddress;
     txt_city.Text = customer.city;
     txt_customerdesc.Text = customer.customerdesc;
     txt_email.Text = customer.email;
     txt_cw_accountname.Text = customer.accountname;
     txt_cw_accountno.Text = customer.accountno;
     txt_cw_address.Text = customer.invoiceaddress;
     txt_cw_bank.Text = customer.bank;
     txt_cw_taxcode.Text = customer.taxcode;
     txt_fax.Text = customer.fax;
     txt_postcode.Text = customer.postcode;
     txt_productinfo.Text = customer.productinfo;
     txt_phone.Text = customer.phone;
     txt_province.Text = customer.province;
     txt_remark.Text = customer.remarks;
     cmb_companytype.SelectedText = customer.companytype;
     cmb_customertype.SelectedText = customer.customertype;
     cmb_profession.SelectedText = customer.profession;
 }
Exemple #21
0
        public ResponseBase InsertOrUpdate(CustomerModel model)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    var result = new ResponseBase();
                    if (CheckExists(model.Name.Trim().ToUpper(), model.Id, model.CompanyId))
                    {
                        result.IsSuccess = false;
                        result.Errors.Add(new Error()
                        {
                            MemberName = "Insert Customer Type", Message = "Khách hàng này đã tồn tại. Vui lòng chọn lại Tên khác !."
                        });
                        return(result);
                    }
                    else
                    {
                        T_Customer obj;
                        if (model.Id == 0)
                        {
                            obj = new T_Customer();
                            Parse.CopyObject(model, ref obj);
                            obj.CreatedDate = DateTime.Now;
                            obj.CreatedUser = model.ActionUser;
                            db.T_Customer.Add(obj);
                        }
                        else
                        {
                            obj = db.T_Customer.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
                            if (obj == null)
                            {
                                result.IsSuccess = false;
                                result.Errors.Add(new Error()
                                {
                                    MemberName = "Update Customer Type", Message = "Khách hàng bạn đang thao tác đã bị xóa hoặc không tồn tại. Vui lòng kiểm tra lại !."
                                });
                                return(result);
                            }
                            else
                            {
                                obj.CompanyId   = model.CompanyId;
                                obj.Name        = model.Name;
                                obj.Description = model.Description;
                                obj.UpdatedUser = model.ActionUser;
                                obj.UpdatedDate = DateTime.Now;

                                //  cap nhat ben phan tich mat hang
                                var commoAna = db.T_CommodityAnalysis.Where(x => !x.IsDeleted && x.ObjectId == obj.Id && x.ObjectType == (int)eObjectType.isCommodity);
                                if (commoAna != null && commoAna.Count() > 0)
                                {
                                    foreach (var item in commoAna)
                                    {
                                        item.Name        = model.Name;
                                        item.UpdatedUser = model.ActionUser;
                                        item.UpdatedDate = DateTime.Now;
                                    }
                                }
                            }
                        }
                        db.SaveChanges();
                        result.IsSuccess = true;
                        return(result);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }