示例#1
0
        private void setGrdThooTranfer()
        {
            DataTable dt = new DataTable();

            dt = lc.lotdb.selectSumByThooTranfer(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString());
            dgvThooTranfer.Rows.Clear();
            Font font = new Font("Microsoft Sans Serif", 12);

            dgvThooTranfer.SelectionMode = DataGridViewSelectionMode.CellSelect;
            if (dt.Rows.Count > 0)
            {
                dgvThooTranfer.RowCount = dt.Rows.Count;
            }
            else
            {
                dgvThooTranfer.RowCount = 1;
            }
            //dgvThooTranfer.RowCount = dt.Rows.Count;
            dgvThooTranfer.ColumnCount             = colTCnt;
            dgvThooTranfer.Columns[colSName].Width = 200;
            dgvThooTranfer.Columns[colSAmt].Width  = 100;
            dgvThooTranfer.Columns[colSPay].Width  = 80;
            dgvThooTranfer.Columns[colSId].Width   = 100;

            //dgvRate.Columns[colRRow].HeaderText = "ลำดับ";
            dgvThooTranfer.Columns[colTName].HeaderText = "เจ้ามือ";
            dgvThooTranfer.Columns[colTAmt].HeaderText  = "ยอด";
            dgvThooTranfer.Columns[colTPay].HeaderText  = "จ่าย";
            dgvThooTranfer.Columns[colTId].HeaderText   = " ";
            dgvThooTranfer.Columns[colTAmt].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
            dgvThooTranfer.Columns[colTPay].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
            dgvThooTranfer.ReadOnly = true;

            if (dt.Rows.Count > 0)
            {
                dgvThooTranfer.RowCount = dt.Rows.Count;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //dgvRate[colRRow, i].Value = (i + 1);
                    cItem = lc.getCboItem(cboThoo, dt.Rows[i][lc.lotdb.lot.thooTranferId].ToString());
                    dgvThooTranfer[colTName, i].Value = cItem.Text;
                    dgvThooTranfer[colTAmt, i].Value  = String.Format("{0:#,###,###.00}", dt.Rows[i]["amt"]);
                    dgvThooTranfer[colTPay, i].Value  = "";
                    dgvThooTranfer[colTId, i].Value   = dt.Rows[i][lc.lotdb.lot.thooTranferId].ToString();
                    //dgvRate[colRDiscount, i].Value = dt.Rows[i][lc.ratedb.rate.discount].ToString();
                    //dgvRate[colRId, i].Value = dt.Rows[i][lc.ratedb.rate.Id].ToString();
                    dgvThooTranfer.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml(lc.getThooBackColorByThoId(dt.Rows[i][lc.lotdb.lot.thooTranferId].ToString()));
                    //if ((i % 2) != 0)
                    //{
                    //    dgvThooTranfer.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon;
                    //}
                }
            }
            dgvThooTranfer.RowHeadersVisible       = false;
            dgvThooTranfer.Columns[colSId].Visible = false;
            //dgvSale.Columns[colRRow].Visible = false;
            dgvThooTranfer.ReadOnly = true;
            dgvThooTranfer.Font     = font;
            //setDataGrdThoo();
            //setThooAmount();
        }