コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Customer objCustomer = new Customer();

            List<Customer> myList = objCustomer.GetAllCustomer(_company.CompanyId);

            objCustomer.CustomerId = myList.Count;
            objCustomer.CustomerName = txtCustomerName.Value;
            objCustomer.CustomerCategoryId =int.Parse(txtCustomerCategory.Value);
            objCustomer.SalesPersonId = int.Parse(salesPersonDropDownList.SelectedItem.Value);
            objCustomer.IsActive = chkIsActive.Checked;
            objCustomer.CompanyId = _company.CompanyId;
            objCustomer.CreditLimit = int.Parse(txtCreditLimit.Value);
            objCustomer.UpdateBy = _user.UserId;
            objCustomer.UpdateDate=DateTime.Now;

            Addresses address = new Addresses();
            List<Addresses> addresseses = address.GetAllAddresses(_company.CompanyId);
            address.AddressId = addresseses.Count;
            address.SourceType = "Customer";
            address.SourceId = _user.UserId;
            address.AddressType = "Main Address";
            address.AddressLine1 = txtAddressLine1.Value;
            address.AddressLine2 = txtAddressLine2.Value;
            address.CountryId = countryDropDownList.SelectedIndex;
            address.City = txtCity.Value;
            address.ZipCode = txtZipCode.Value;
            address.Phone = txtPhoneNo.Value;
            address.Mobile = txtPhoneNo.Value;
            address.Email = txtEmail.Value;
            address.Web = txtWeb.Value;
            address.CompanyId = _company.CompanyId;

            int chk1 = objCustomer.InsertCustomer();
            int chk2=address.InsertAddresses();
            if (chk1 > 0 && chk2 > 0)
                {
                    Session["savedCutomerMessage"] = "Saved Successfully";
                    Response.Redirect(Request.RawUrl);

                }
                else
                {
                    Alert.Show("Error occured while inserting customer information");
                }
        }
コード例 #2
0
        private void LoadCustomerTable()
        {
            try
            {
                customerTblBody.InnerHtml = "";
                string htmlContent = "";
                Customer customer=new Customer();
                List<Customer> allCustomers = customer.GetAllCustomer(_company.CompanyId);
                foreach (Customer cust in allCustomers)
                {
                    htmlContent += "<tr>";
                    htmlContent += String.Format(@"<th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th><th>{4}</th>", cust.CustomerName, cust.CustomerCategoryId, cust.SalesPersonId,cust.CreditLimit, cust.UpdateDate);
                    htmlContent += "</tr>";
                }

                customerTblBody.InnerHtml += htmlContent;
            }
            catch (Exception exc)
            {
                Alert.Show(exc.Message);
            }
        }
コード例 #3
0
        private void LoadCustomerTable()
        {
            try
            {
                Customer objCustomer = new Customer();
                objCustomerList = objCustomer.GetAllCustomer(_company.CompanyId);
                if (objCustomerList.Count == 0)
                {
                    objCustomerList.Add(new Customer());
                }
                foreach (Customer objCst in objCustomerList)
                {
                    List<string> countryList = Country.CountryList();
                    List<Addresses> addressList =new Addresses().GetAllAddresses(_company.CompanyId);
                    foreach (Addresses address in addressList)
                    {
                        if (address.SourceType == "Customer" && address.SourceId == objCst.CustomerId)
                        {
                            objCst.AddressId = address.AddressId;
                            objCst.AddressLine1 = address.AddressLine1;
                            objCst.AddressLine2 = address.AddressLine2;
                            objCst.AddressType = address.AddressType;
                            objCst.City = address.City;
                            objCst.ZipCode = address.ZipCode;
                            objCst.Phone = address.Phone;
                            objCst.Mobile = address.Mobile;
                            objCst.Email = address.Email;
                            objCst.Web = address.Web;
                            objCst.CountryName = countryList[address.CountryId];

                            break;
                        }

                    }

                }
                RadGrid1.DataSource = objCustomerList;
                RadGrid1.Rebind();

            }
            catch (Exception ex)
            {

                Alert.Show(ex.Message);

            }
        }