Ejemplo n.º 1
0
        public void setControl()
        {
            DataTable dt = new DataTable();

            dt = lc.selectRateAll();
            dgvView.ColumnCount = colCnt;

            dgvView.RowCount                      = dt.Rows.Count + 1;
            dgvView.SelectionMode                 = DataGridViewSelectionMode.FullRowSelect;
            dgvView.Columns[colRow].Width         = 50;
            dgvView.Columns[colDescription].Width = 200;
            dgvView.Columns[colRec].Width         = 120;
            dgvView.Columns[colpay].Width         = 120;
            dgvView.Columns[colDiscount].Width    = 120;
            dgvView.Columns[colLimit].Width       = 120;
            dgvView.Columns[colId].Width          = 80;

            dgvView.Columns[colRow].HeaderText         = "ลำดับ";
            dgvView.Columns[colpay].HeaderText         = "จ่าย บาท";
            dgvView.Columns[colDescription].HeaderText = "รายการ";
            dgvView.Columns[colRec].HeaderText         = "ซื้อ บาท";
            dgvView.Columns[colDiscount].HeaderText    = "ส่วนลด บาท";
            dgvView.Columns[colLimit].HeaderText       = "จำนวนอั้น บาท";
            dgvView.Columns[colId].HeaderText          = "id";//

            dgvView.Columns[colId].HeaderText = "id";
            Font font = new Font("Microsoft Sans Serif", 12);

            dgvView.Font = font;
            dgvView.Columns[colId].Visible = false;
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dgvView[colRow, i].Value         = (i + 1);
                    dgvView[colpay, i].Value         = dt.Rows[i][lc.ratedb.rate.pay].ToString();
                    dgvView[colDescription, i].Value = dt.Rows[i][lc.ratedb.rate.Description].ToString();
                    dgvView[colRec, i].Value         = dt.Rows[i][lc.ratedb.rate.rec].ToString();
                    dgvView[colLimit, i].Value       = dt.Rows[i][lc.ratedb.rate.limit1].ToString();
                    dgvView[colDiscount, i].Value    = dt.Rows[i][lc.ratedb.rate.discount].ToString();
                    dgvView[colId, i].Value          = dt.Rows[i][lc.ratedb.rate.Id].ToString();

                    if ((i % 2) != 0)
                    {
                        dgvView.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void setGrdRate()
        {
            DataTable dt = new DataTable();

            dt = lc.selectRateAll();
            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[colRpay].Width         = 110;
            dgvRate.Columns[colRDiscount].Width    = 100;
            dgvRate.Columns[colRLimit].Width       = 120;
            dgvRate.Columns[colRId].Width          = 80;
            dgvRate.Columns[colRAmt].Width         = 110;

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

            dgvRate.Columns[colRpay].DefaultCellStyle.Alignment      = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRRec].DefaultCellStyle.Alignment      = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRDiscount].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRAmt].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[colRpay, i].Value         = dt.Rows[i][lc.ratedb.rate.pay].ToString();
                    dgvRate[colRDescription, i].Value = dt.Rows[i][lc.ratedb.rate.Description].ToString();
                    dgvRate[colRRec, i].Value         = dt.Rows[i][lc.ratedb.rate.rec].ToString();
                    dgvRate[colRLimit, i].Value       = dt.Rows[i][lc.ratedb.rate.limit1].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();

                    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.Font = font;
            //setDataGrdThoo();
            //setThooAmount();
        }
Ejemplo n.º 3
0
        private void setGrdRate()
        {
            pB1.Show();
            String    rateId = "";
            DataTable dt     = new DataTable();

            Double[] reward = new Double[2] {
                0, 0
            };
            double amt = 0, amt1 = 0;

            dt = lc.selectRateAll();
            dgvRate.Rows.Clear();
            Font font  = new Font("Microsoft Sans Serif", 12);
            Font font1 = new Font("Microsoft Sans Serif", 12, FontStyle.Bold);

            dgvRate.SelectionMode = DataGridViewSelectionMode.CellSelect;
            if (dt.Rows.Count > 0)
            {
                dgvRate.RowCount = dt.Rows.Count + 1;     // +1 เพราะ row สุดท้ายไว้ summary
            }
            else
            {
                dgvRate.RowCount = 1;
            }
            //dgvRate.RowCount = dt.Rows.Count;
            dgvRate.ColumnCount                    = 11;
            dgvRate.Columns[colRRow].Width         = 50;
            dgvRate.Columns[colRDescription].Width = 200;
            dgvRate.Columns[colRRec].Width         = 60;
            dgvRate.Columns[colRReward].Width      = 100;
            dgvRate.Columns[colRpayRate].Width     = 100;
            dgvRate.Columns[colRDiscount].Width    = 100;
            dgvRate.Columns[colRLimit].Width       = 120;
            dgvRate.Columns[colRId].Width          = 80;
            dgvRate.Columns[colRAmtReward].Width   = 100;
            dgvRate.Columns[colRAmt].Width         = 100;
            dgvRate.Columns[colRNetTotal].Width    = 100;

            dgvRate.Columns[colRRow].HeaderText         = "ลำดับ";
            dgvRate.Columns[colRpayRate].HeaderText     = "อัตราจ่าย";
            dgvRate.Columns[colRDescription].HeaderText = "รายการ";
            dgvRate.Columns[colRRec].HeaderText         = "ซื้อ";
            dgvRate.Columns[colRReward].HeaderText      = "จ่าย";
            //dgvRate.Columns[colRRec].HeaderText = "ซื้อ";
            dgvRate.Columns[colRDiscount].HeaderText  = "ส่วนลด";
            dgvRate.Columns[colRLimit].HeaderText     = "จำนวนอั้น";
            dgvRate.Columns[colRAmt].HeaderText       = "ยอดเงิน";
            dgvRate.Columns[colRAmtReward].HeaderText = "แทงถูก";
            dgvRate.Columns[colRNetTotal].HeaderText  = "คงเหลือ";
            dgvRate.Columns[colRId].HeaderText        = "id";//

            dgvRate.Columns[colRpayRate].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRRec].DefaultCellStyle.Alignment       = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRReward].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRDiscount].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRLimit].DefaultCellStyle.Alignment     = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRAmtReward].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRAmt].DefaultCellStyle.Alignment       = DataGridViewContentAlignment.BottomRight;
            dgvRate.Columns[colRNetTotal].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.BottomRight;
            //dgvRate.ReadOnly = true;

            if (dt.Rows.Count > 0)
            {
                pB1.Maximum = dt.Rows.Count;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    pB1.Value = i;
                    rateId    = dt.Rows[i][lc.ratedb.rate.Id].ToString();
                    reward    = lc.lotdb.selectSumByRateReward(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString(), rateId);
                    amt       = lc.lotdb.selectSumByRate(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString(), rateId);
                    dgvRate[colRRow, i].Value         = (i + 1);
                    dgvRate[colRpayRate, i].Value     = String.Format("{0:#,###,###.00}", dt.Rows[i][lc.ratedb.rate.pay]);
                    dgvRate[colRDescription, i].Value = dt.Rows[i][lc.ratedb.rate.Description].ToString();
                    dgvRate[colRRec, i].Value         = dt.Rows[i][lc.ratedb.rate.rec].ToString();
                    dgvRate[colRLimit, i].Value       = String.Format("{0:#,###,###.00}", dt.Rows[i][lc.ratedb.rate.limit1]);
                    //dgvRate[colRDiscount, i].Value = dt.Rows[i][lc.ratedb.rate.discount].ToString();
                    dgvRate[colRId, i].Value        = rateId;
                    dgvRate[colRAmtReward, i].Value = String.Format("{0:#,###,###.00}", reward[0]);
                    dgvRate[colRReward, i].Value    = String.Format("{0:#,###,###.00}", reward[1]);
                    dgvRate[colRAmt, i].Value       = String.Format("{0:#,###,###.00}", amt);
                    amt1 += amt;
                    if (Double.Parse(lc.cf.NumberNull(dgvRate[colRReward, i].Value.ToString())) > 0)
                    {
                        dgvRate[colRReward, i].Style.Font         = font1;
                        dgvRate[colRReward, i].Style.ForeColor    = Color.Red;
                        dgvRate[colRAmtReward, i].Style.Font      = font1;
                        dgvRate[colRAmtReward, i].Style.ForeColor = Color.Red;
                    }
                    if (rateId.Equals("up"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#174e75");
                    }
                    else if (rateId.Equals("down"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#174e75");
                    }
                    else if (rateId.Equals("2down"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#789640");
                    }
                    else if (rateId.Equals("2up"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#789640");
                    }
                    else if (rateId.Equals("2tod"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#789640");
                    }
                    else if (rateId.Equals("3down"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#788540");
                    }
                    else if (rateId.Equals("3tod"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#788540");
                    }
                    else if (rateId.Equals("3up"))
                    {
                        dgvRate.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#788540");
                    }
                    //if ((i % 2) != 0)
                    //{
                    //    dgvRate.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon;
                    //}
                }
            }
            dgvRate[colRAmt, dgvRate.RowCount - 1].Value = String.Format("{0:#,###,###.00}", amt1);
            dgvRate.RowHeadersVisible             = false;
            dgvRate.Columns[colRId].Visible       = false;
            dgvRate.Columns[colRRow].Visible      = false;
            dgvRate.Columns[colRDiscount].Visible = false;
            dgvRate.ReadOnly = true;
            dgvRate.Font     = font;
            pB1.Hide();
            //setDataGrdThoo();
            //setThooAmount();
        }