Exemplo n.º 1
0
        //private void combCustomerLive_DrawItem(object sender, DrawItemEventArgs e)
        //{
        //    e.DrawBackground();
        //    e.DrawFocusRectangle();
        //    e.Graphics.DrawString(((DataRowView)combCustomerLive.Items[e.Index]).Row[combCustomerLive.DisplayMember].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds, new System.Drawing.StringFormat());
        //}

        private void dgvCustomerLive_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = sender as DataGridView;

            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                customerLive.cusID          = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
                customerLive.floorNum       = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                customerLive.roomID         = dgv.Rows[e.RowIndex].Cells[2].Value.ToString();
                customerLive.startLiveTime  = DateTime.Parse(dgv.Rows[e.RowIndex].Cells[3].Value.ToString());
                customerLive.proEndLiveTime = DateTime.Parse(dgv.Rows[e.RowIndex].Cells[4].Value.ToString());
                customerLive.endLiveTime    = DateTime.Parse(dgv.Rows[e.RowIndex].Cells[5].Value.ToString());
                customerLive.isAccount      = dgv.Rows[e.RowIndex].Cells[6].Value.ToString() == "是" ? 1 : 0;
            }
            else
            {
                customerLive = new Model.CustomerLive();
                if (sortOrder == 0)
                {
                    dgv.Sort(dgv.Columns[e.ColumnIndex], ListSortDirection.Descending);
                    sortOrder++;
                }
                else
                {
                    dgv.Sort(dgv.Columns[e.ColumnIndex], ListSortDirection.Ascending);
                    sortOrder--;
                }
            }
        }
Exemplo n.º 2
0
        private void SearchCustomerLive(string sqlString)
        {
            customerLive = new Model.CustomerLive();
            DataSet ds = new BLL.CustomerLive().GetListCustomerLive(sqlString);

            if (ds.Tables["ds"].Rows.Count == 0)
            {
                MessageBox.Show("查无结果!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                dgvCustomerLive.DataSource = ds.Tables["ds"];
                int columnNumber = dgvCustomerLive.ColumnCount;
                foreach (DataGridViewColumn col in dgvCustomerLive.Columns)
                {
                    col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    col.SortMode   = DataGridViewColumnSortMode.NotSortable;
                    col.FillWeight = 100 / columnNumber;
                }
                dgvCustomerLive.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dgvCustomerLive.AllowUserToAddRows = false;
                dgvCustomerLive.RowHeadersVisible  = false;
                dgvCustomerLive.ReadOnly           = true;
            }
        }
Exemplo n.º 3
0
        public void LoadData_CustomerLiveInfo()
        {
            customerLive   = new Model.CustomerLive();
            dsCustomerLive = new BLL.CustomerLive().GetListCustomerLive("");

            dgvCustomerLive.DataSource = dsCustomerLive.Tables["ds"];
            int columnNumber = dgvCustomerLive.ColumnCount;

            foreach (DataGridViewColumn col in dgvCustomerLive.Columns)
            {
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                col.SortMode   = DataGridViewColumnSortMode.NotSortable;
                col.FillWeight = 100 / columnNumber;
            }
            dgvCustomerLive.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvCustomerLive.AllowUserToAddRows = false;
            dgvCustomerLive.RowHeadersVisible  = false;
            dgvCustomerLive.ReadOnly           = true;
        }