public CustomerGrid GetAllCustomers(CustomerSearchObject searchObject)
        {
            var gridPageSize = searchObject.PageSize ?? Utility.PageSize;

            var customerService = CustomerService.GetInstance();

            int totalCount     = 0;
            var navigationList = new List <Navigations>
            {
                Navigations.City,
            };
            var data = (from c in customerService.GetDefaultQuery(searchObject, navigationList, out totalCount)
                        select new CustomerViewModel
            {
                Id = c.Id,
                FullName = c.FullName,
                ManagerName = c.ManagerName,
                Mobile = c.Mobile,
                City = c.City,
            });

            var gridData = new CustomerGrid
            {
                CustomerList = data.ToList(),
                PageCount    = Utility.CalculatePageSize(totalCount, gridPageSize),
                PageSize     = gridPageSize
            };

            return(gridData);
        }
Ejemplo n.º 2
0
        private void CustomerTableView_InitNewRow(object sender, InitNewRowEventArgs e)
        {
            var row = CustomerGrid.GetRow(e.RowHandle) as Customer;

            row.RowState    = Convert.ToInt16(ERowState.Active);
            FocusedCustomer = row;
            CustomerGrid.Focus();
            OnPropertyChanged("IsDataModified");
        }
    void GetAllCustomer()
    {
        string sqlstr;

        sqlstr = "select CustomerID,CompanyName, RegionID, Picture from Customers ";


        CustomerGrid.DataSource = mydb.BuildDataTable(sqlstr);;
        CustomerGrid.DataBind();
    }
Ejemplo n.º 4
0
 public void Load(int contactID)
 {
     Customers = _dc.Customer.Where(x => x.RowState == Convert.ToInt16(ERowState.Active));
     if (_dc.Contact.Any(x => x.ID == contactID))
     {
         ContactGrid.Focus();
         FocusedContact  = _dc.Contact.Single(x => x.ID == contactID);
         FocusedCustomer = FocusedContact.Customer;
     }
     else
     {
         CustomerGrid.Focus();
     };
 }
Ejemplo n.º 5
0
 public void BindGrid()
 {
     try
     {
         string           cstring = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
         MySqlConnection  con     = new MySqlConnection(cstring);
         MySqlCommand     cmd     = new MySqlCommand("SELECT CustomerID,CompanyName,ContactTitle,City,PostalCode,Phone,Fax from Customers", con);
         MySqlDataAdapter sda     = new MySqlDataAdapter();
         sda.SelectCommand = cmd;
         DataSet ds = new DataSet();
         sda.Fill(ds);
         CustomerGrid.DataSource = ds;
         CustomerGrid.DataBind();
     }
     catch (Exception)
     {
         Response.Redirect(objconstmsg.strerrorpage, false);
     }
 }
        private void btn_Click_Edit_Customer(object sender, RoutedEventArgs e)
        {
            if (CustomerGrid.SelectedItems.Count == 1)
            {
                CustomerViewModel    rowViewModel = CustomerGrid.SelectedItem as CustomerViewModel;
                CustomerDetailWindow detailWindow = new CustomerDetailWindow();

                detailWindow.DataContext = rowViewModel.Clone();;

                DataGridViewModel gridViewModel = (DataGridViewModel)this.DataContext;
                rowViewModel.ParentGrid = gridViewModel;
                rowViewModel.DetailWindowDatacontext = detailWindow.DataContext;
                CustomerGrid.UnselectAllCells();
                bool?result = detailWindow.ShowDialog();
            }
            else
            {
                ShowMessageDialog("Kunde bearbeiten - Info", "Ein Datensatz muss zuvor selektiert werden", MessageDialogStyle.Affirmative);
            }
        }
        private void btn_Click_Update_Customers(object sender, RoutedEventArgs e)
        {
            CustomerGrid.CommitEdit();
            CustomerGrid.UnselectAllCells();
            DataGridViewModel gridViewModel = (DataGridViewModel)CustomerGrid.DataContext;

            try
            {
                if (gridViewModel.CustomersInfo.Count > 0)
                {
                    gridViewModel.UpdateAllCustomers();
                    CustomerGrid.DataContext = new DataGridViewModel();
                    var customersUpdated = ((DataGridViewModel)CustomerGrid.DataContext).CustomersInfo.Count();
                    ShowMessageDialog("Kunden aktualisiert", customersUpdated == 1 ? customersUpdated + " Datensatz wurde aktualisiert" : customersUpdated + " Datensätze wurden aktualisiert", MessageDialogStyle.Affirmative);
                }
            }
            catch (System.InvalidOperationException ex)
            {
                ShowMessageDialog("Sorting ist während einer AddNew- oder EditItem-Transaktion nicht zulässig.", "Aktualisierung erforderlich.", MessageDialogStyle.Affirmative);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TcCustomers"/> class.
 /// </summary>
 public TcCustomers()
 {
     mTableView = new Lazy <TcOptimizedTableView <TcCustomerRow> >(() => CustomerGrid.GetOptimizedTableView(underlyingRow => new TcCustomerRow(underlyingRow)));
 }
Ejemplo n.º 9
0
 private void BindData()
 {
     _customers = _repo.GetAll();
     CustomerGrid.DataSource = _customers;
     CustomerGrid.DataBind();
 }
Ejemplo n.º 10
0
 protected void btnNewCustomer_Click(object sender, EventArgs e)
 {
     CustomerGrid.AddNewRow();
 }
 private void btn_Click_UnselectAllRows_Customer(object sender, RoutedEventArgs e)
 {
     CustomerGrid.UnselectAllCells();
 }
        // Checks the Order by value and fires the query to display the customer information by given order and display the data grid.
//		private void DropOrderBy_SelectedIndexChanged(object sender, System.EventArgs e)
//		{

//			if(DropOrderBy.SelectedIndex == 0)
//			{
//                MessageBox.Show("Please Select Display Order");
//				return;
//			}
//			string order_by = "Cust_Name";
//			if(DropOrderBy.SelectedItem.Text == "Customer Type")
//				order_by = "Cust_Type";
//
//			if(DropOrderBy.SelectedItem.Text == "Customer City")
//				order_by = "City";
//
//			try
//			{
//				SqlDataReader SqlDtr = null;
//
//				dbobj.SelectQuery("Select * from Customer order by "+order_by+" asc",ref SqlDtr);
//				CustomerGrid.DataSource = SqlDtr;
//				CustomerGrid.DataBind();
//
//				if(CustomerGrid.Items.Count==0)
//				{
//					MessageBox.Show("Data not available");
//					CustomerGrid.Visible=false;
//				}
//				else
//				{
//					CustomerGrid.Visible=true;
//				}
//				SqlDtr.Close ();
//			}
//			catch(Exception ex)
//			{
//				CreateLogFiles.ErrorLog("Form:CustomerDataMining.aspx,Method:DropOrderBy_SelectedIndexChanged  EXCEPTION  "+ex.Message+"  User: "******"Servosms"]);
            string        sql       = "";
            string        Cust_Name = "";

            if (DropSearchBy.SelectedIndex == 0)
            {
                sql = "Select * from Customer";
            }
            else
            {
                if (DropValue.Value == "All")
                {
                    sql = "Select * from Customer";
                }
                else if (DropSearchBy.SelectedIndex == 1)
                {
                    //coment by vikas 25.05.09 sql="Select * from Customer where cust_name='"+DropValue.Value+"'";
                    /*******Add by vikas sharma 25.05.09************************/
                    Cust_Name = DropValue.Value.Substring(0, DropValue.Value.IndexOf(":"));
                    sql       = "Select * from Customer where cust_name='" + Cust_Name.ToString() + "'";
                    /*******Add by vikas sharma 25.05.09************************/
                }                /******Add by vikas 17.11.2012*********************/
                else if (DropSearchBy.SelectedIndex == 2)
                {
                    sql = "Select * from Customer where cust_id in(select cust_id from customer c,customertype ct where c.cust_type=ct.customertypename and group_Name ='" + DropValue.Value + "')";
                }
                else if (DropSearchBy.SelectedIndex == 3)
                {
                    sql = "Select * from Customer where cust_id in(select cust_id from customer c,customertype ct where c.cust_type=ct.customertypename and sub_group_Name ='" + DropValue.Value + "')";               /****End******/
                }
                else if (DropSearchBy.SelectedIndex == 4)
                {
                    sql = "Select * from Customer where state='" + DropValue.Value + "'";
                }
                else if (DropSearchBy.SelectedIndex == 5)
                {
                    sql = "Select * from Customer where city='" + DropValue.Value + "'";
                }
                else if (DropSearchBy.SelectedIndex == 6)
                {
                    sql = "Select * from Customer where ssr=(select emp_id from employee where emp_name='" + DropValue.Value + "')";
                }
            }
            sql += " order by cust_name";
            SqlDataAdapter da = new SqlDataAdapter(sql, sqlcon);
            DataSet        ds = new DataSet();

            da.Fill(ds, "customer");
            DataTable dtcustomer = ds.Tables["customer"];
            //da.Fill(ds,"beat_master","machanic_entry","customermechanicentry ","customer");
            //DataTable dtcustomer=ds.Tables["beat_master","machanic_entry","customermechanicentry ","customer"];
            DataView dv = new DataView(dtcustomer);

            dv.Sort             = strorderby;
            Cache["strorderby"] = strorderby;
            if (chkTesting.Checked)
            {
                CustomerTestGrid.DataSource = dv;
            }
            else
            {
                CustomerGrid.DataSource = dv;
            }
            if (dv.Count != 0)
            {
                if (chkTesting.Checked)
                {
                    CustomerTestGrid.DataBind();
                    CustomerTestGrid.Visible = true;
                    CustomerGrid.Visible     = false;
                }
                else
                {
                    CustomerGrid.DataBind();
                    CustomerTestGrid.Visible = false;
                    CustomerGrid.Visible     = true;
                }
            }
            else
            {
                CustomerGrid.Visible     = false;
                CustomerTestGrid.Visible = false;
                MessageBox.Show("Data Not Available");
            }
            sqlcon.Dispose();
        }
Ejemplo n.º 13
0
 protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     CustomerGrid.PageIndex = e.NewPageIndex;
     BindGrid();
     CustomerGrid.DataBind();
 }