Ejemplo n.º 1
0
 private void txtFilter_TextChanged(object sender, EventArgs e)
 {
     using (Business.Customers customers = new Business.Customers())
     {
         dgvcustomers.DataSource = customers.Get(w => w.FullName.Contains(txtFilter.Text.Trim()) || w.Address.Contains(txtFilter.Text.Trim()) || w.Email.Contains(txtFilter.Text.Trim()));
     }
 }
Ejemplo n.º 2
0
 private void DataBinding()
 {
     using (Business.Customers customers = new  Business.Customers())
     {
         dgvcustomers.DataSource = customers.Get();// customers.Get();
     }
 }
Ejemplo n.º 3
0
 private void btnDeleteCustomer_Click(object sender, EventArgs e)
 {
     if (dgvcustomers.CurrentRow != null)
     {
         using (Business.Customers customers = new Business.Customers())
         {
             int customerid = int.Parse(dgvcustomers.CurrentRow.Cells[0].Value.ToString());
             customers.DeleteByID(customerid);
             customers.Save();
         }
     }
     else
     {
         MessageBox.Show("یک خط انتخاب کنید");
     }
 }
Ejemplo n.º 4
0
 private void frm_AddCustomer_Load(object sender, EventArgs e)
 {
     if (this.CustomerID != 0)
     {
         this.Text          = "ویرایش";
         btninsertdata.Text = "ویرایش";
         using (Business.Customers UOW = new  Business.Customers())
         {
             var sel = UOW.Get(w => w.ID == CustomerID).FirstOrDefault();
             txtAddress.Text  = sel.Address;
             txtEmail.Text    = sel.Email;
             txtMobile.Text   = sel.Mobile;
             txtName.Text     = sel.FullName;
             pc.ImageLocation = Application.StartupPath + "/Image/" + sel.Image;
         }
     }
 }
Ejemplo n.º 5
0
        private void btninsertdata_Click(object sender, EventArgs e)
        {
            if (BaseValidator.IsFormValid(this.components))
            {
                string locationName = string.Empty;
                if (pc.Image != null)
                {
                    locationName = Guid.NewGuid().ToString() + Path.GetExtension(pc.ImageLocation);
                    if (!Directory.Exists(Application.StartupPath + "/Images/"))
                    {
                        Directory.CreateDirectory(Application.StartupPath + "/Images/");
                    }
                    pc.Image.Save(Application.StartupPath + "/Images/" + locationName);
                }

                using (Business.Customers UOW = new Business.Customers())
                {
                    DataLayer.Customers customer = new DataLayer.Customers()
                    {
                        Address  = txtAddress.Text.Trim(),
                        Email    = txtEmail.Text.Trim(),
                        FullName = txtName.Text.Trim(),
                        Mobile   = txtMobile.Text.Trim(),
                        Image    = locationName
                    };
                    if (CustomerID != 0)
                    {
                        customer.ID = CustomerID;
                        UOW.Update(customer);
                    }
                    else
                    {
                        UOW.Insert(customer);
                    }

                    UOW.Save();
                }
            }
        }