Ejemplo n.º 1
0
        private void setGrdRate()
        {
            DataTable dt = new DataTable();

            if (s.statusDiscount.Equals("1"))
            {
                dt = lc.srdb.selectBySale(s.Id);
                if (dt.Rows.Count <= 0)
                {
                    dt = lc.selectRateAlltoSaleRate();
                }
            }
            else
            {
                dgvRate.Visible = false;
                return;
            }

            dgvRate.Rows.Clear();
            Font font = new Font("Microsoft Sans Serif", 12);

            dgvRate.SelectionMode                  = DataGridViewSelectionMode.CellSelect;
            dgvRate.RowCount                       = dt.Rows.Count;
            dgvRate.ColumnCount                    = 8;
            dgvRate.Columns[colRRow].Width         = 50;
            dgvRate.Columns[colRDescription].Width = 150;
            dgvRate.Columns[colRRec].Width         = 110;
            dgvRate.Columns[colSaleId].Width       = 110;
            dgvRate.Columns[colRDiscount].Width    = 100;
            dgvRate.Columns[colRLimit].Width       = 120;
            dgvRate.Columns[colRId].Width          = 80;
            dgvRate.Columns[colSRId].Width         = 110;

            dgvRate.Columns[colRRow].HeaderText         = "ลำดับ";
            dgvRate.Columns[colSaleId].HeaderText       = "";
            dgvRate.Columns[colRDescription].HeaderText = "รายการ";
            dgvRate.Columns[colRRec].HeaderText         = "ซื้อ";
            dgvRate.Columns[colRDiscount].HeaderText    = "ส่วนลด";
            dgvRate.Columns[colRLimit].HeaderText       = "จำนวนอั้น";
            dgvRate.Columns[colSRId].HeaderText         = "";
            dgvRate.Columns[colRId].HeaderText          = "id";//

            dgvRate.Columns[colSaleId].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRRec].DefaultCellStyle.Alignment      = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRDiscount].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colSRId].DefaultCellStyle.Alignment      = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRLimit].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.BottomRight;


            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dgvRate[colRRow, i].Value         = (i + 1);
                    dgvRate[colSaleId, i].Value       = lc.cf.stringNull1(dt.Rows[i][lc.srdb.sr.SaleId]);
                    dgvRate[colRDescription, i].Value = lc.cf.stringNull1(dt.Rows[i][lc.srdb.sr.Description]);
                    dgvRate[colRRec, i].Value         = dt.Rows[i][lc.srdb.sr.rec].ToString();
                    dgvRate[colRLimit, i].Value       = String.Format("{0:#,###,###.00}", dt.Rows[i][lc.srdb.sr.limit1]);
                    dgvRate[colRDiscount, i].Value    = String.Format("{0:#,###,###.00}", dt.Rows[i][lc.srdb.sr.discount]);
                    dgvRate[colRId, i].Value          = dt.Rows[i][lc.srdb.sr.RateId].ToString();
                    dgvRate[colSRId, i].Value         = dt.Rows[i][lc.srdb.sr.Id].ToString();

                    if ((i % 2) != 0)
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon;
                    }
                }
            }
            dgvRate.RowHeadersVisible          = false;
            dgvRate.Columns[colRId].Visible    = false;
            dgvRate.Columns[colRRow].Visible   = false;
            dgvRate.Columns[colSaleId].Visible = false;
            dgvRate.Columns[colSRId].Visible   = false;
            dgvRate.Font = font;
            //setDataGrdThoo();
            //setThooAmount();
        }