private void setGridLot() { setGridLotto(1); ComboBoxItem iStaff = (ComboBoxItem)cboStaff.SelectedItem; ComboBoxItem iSale; DataTable dt = new DataTable(); dt = lc.lotdb.selectSumByStaff(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString(), iStaff.Value); if (dt.Rows.Count > 0) { setGridLotto(dt.Rows.Count); for (int i = 0; i < dt.Rows.Count; i++) { dgvLotto[colLottoUp, i].Value = String.Format("{0:#,###,###.00}", dt.Rows[i]["up11"]); dgvLotto[colLottoDown, i].Value = String.Format("{0:#,###,###.00}", dt.Rows[i]["down11"]); dgvLotto[colLottoTod, i].Value = String.Format("{0:#,###,###.00}", dt.Rows[i]["tod1"]); dgvLotto[colLottoId, i].Value = dt.Rows[i][lc.lotdb.lot.lottoId].ToString(); dgvLotto[colLottoNumber, i].Value = dt.Rows[i][lc.lotdb.lot.lottoId].ToString(); iSale = lc.getCboItem(cboSale1, dt.Rows[i][lc.lotdb.lot.saleId].ToString()); dgvLotto[colSale, i].Value = iSale.Text; dgvLotto[colLottoVoid, i].Value = "ยกเลิก"; if ((i % 2) != 0) { dgvLotto.Rows[i].DefaultCellStyle.BackColor = Color.Cornsilk; } } } }
private void setControl(String rowId) { //ComboBoxItem aa = new ComboBoxItem(); lot = lc.selectLottobyPk(rowId); txtInput.Text = lot.number; txtUp.Text = lot.up; txtTod.Text = lot.tod; txtDown.Text = lot.down; txtRowId.Text = lot.rowId; txtLotId.Text = lot.lottoId; cboThoo.SelectedItem = lc.getCboItem(cboThoo, lot.thooId); cboStaff.SelectedItem = lc.getCboItem(cboStaff, lot.staffId); cboSale.SelectedItem = lc.getCboItem(cboSale, lot.saleId); //cboThoo.SelectedValue = lc.getCboItem(cboThoo, lot.thooId); cboYear.Text = lot.yearId; cboMonth.SelectedValue = lot.monthId; cboPeriod.SelectedValue = lot.periodId; //rw.dateReward; }
private void setDataGrid1(DataGridView dgv, int row, String number, Double numUp, Double numTod, Double numDown, String rowId, String lottoId, String use1, String statusOL, String OLUp, String OLTod, String OLDown, String thooTranferId) { if (dgv.Enabled == false) { return; } if (dgv1.RowCount <= row) { return; } dgv[colNumber, row].Value = number; dgv[colUp, row].Value = String.Format("{0:#,###,###.00}", numUp); dgv[colTod, row].Value = String.Format("{0:#,###,###.00}", numTod); dgv[colDown, row].Value = String.Format("{0:#,###,###.00}", numDown); dgv[colRowId, row].Value = rowId; dgv[colLottoId1, row].Value = lottoId; dgv[colUse1, row].Value = use1; dgv[colStatusOL, row].Value = statusOL; if (OLUp.Equals("0.00")) { dgv[colOLUp, row].Value = ""; } else { dgv[colOLUp, row].Value = OLUp; } if (OLTod.Equals("0.00")) { dgv[colOLTod, row].Value = ""; } else { dgv[colOLTod, row].Value = OLTod; } if (OLDown.Equals("0.00")) { dgv[colOLDown, row].Value = ""; } else { dgv[colOLDown, row].Value = OLDown; } dgv[colThooTranferId, row].Value = thooTranferId; cItem = lc.getCboItem(cboThoo, thooTranferId); dgv[colThooTranferName, row].Value = cItem.Text; //row++; }
private void setGrdSale() { DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); double amt = 0, amt1 = 0, amt2 = 0; dt = lc.lotdb.selectSumBySale(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString()); dgvSale.Rows.Clear(); Font font = new Font("Microsoft Sans Serif", 12); dgvSale.SelectionMode = DataGridViewSelectionMode.CellSelect; if (dt.Rows.Count > 0) { dgvSale.RowCount = dt.Rows.Count + 1; //// +1 เพราะ row สุดท้ายไว้ summary } else { dgvSale.RowCount = 1; } dgvSale.ColumnCount = colSCnt; dgvSale.Columns[colSName].Width = 200; dgvSale.Columns[colSAmt].Width = 100; dgvSale.Columns[colSPay].Width = 80; dgvSale.Columns[colSId].Width = 100; //dgvRate.Columns[colRRow].HeaderText = "ลำดับ"; dgvSale.Columns[colSName].HeaderText = "sale"; dgvSale.Columns[colSAmt].HeaderText = "ยอด"; dgvSale.Columns[colSPay].HeaderText = "%ยอด"; dgvSale.Columns[colS3Up].HeaderText = "3บน"; dgvSale.Columns[colS3Tod].HeaderText = "3โต๊ด"; dgvSale.Columns[colS3Down].HeaderText = "3ล่าง"; dgvSale.Columns[colS2Up].HeaderText = "2บน"; dgvSale.Columns[colS2Tod].HeaderText = "2โต๊ด"; dgvSale.Columns[colS2Down].HeaderText = "2ล่าง"; dgvSale.Columns[colSUp].HeaderText = "วิ่งบน"; dgvSale.Columns[colSDown].HeaderText = "วิ่งล่าง"; dgvSale.Columns[colSStatusDiscount].HeaderText = "แทงถูก"; dgvSale.Columns[colSPerDiscount].HeaderText = "คงเหลือ"; dgvSale.Columns[colSId].HeaderText = " "; dgvSale.Columns[colSAmt].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight; dgvSale.Columns[colSPay].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight; dgvSale.ReadOnly = true; if (dt.Rows.Count > 0) { //dgvSale.RowCount = dt.Rows.Count; for (int i = 0; i < dt.Rows.Count; i++) { Double reward = 0, nettotal = 0; dt1 = new DataTable(); //dgvRate[colRRow, i].Value = (i + 1); cItem = lc.getCboItem(cboSale, dt.Rows[i][lc.saledb.sale.Id].ToString()); dgvSale[colSName, i].Value = cItem.Text; dgvSale[colSAmt, i].Value = String.Format("{0:#,###,###.00}", dt.Rows[i]["amt"]); dgvSale[colSPay, i].Value = lc.getSalePercent(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString(), dt.Rows[i][lc.saledb.sale.Id].ToString()); dt1 = lc.lotdb.selectSumBySale(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString(), dt.Rows[i][lc.saledb.sale.Id].ToString()); dgvSale[colS3Up, i].Value = dt1.Rows[0][lc.lotdb.lot.r3Up].ToString(); dgvSale[colS3Tod, i].Value = dt1.Rows[0][lc.lotdb.lot.r3Tod].ToString(); dgvSale[colS3Down, i].Value = dt1.Rows[0][lc.lotdb.lot.r3Down].ToString(); dgvSale[colS2Up, i].Value = dt1.Rows[0][lc.lotdb.lot.r2Up].ToString(); dgvSale[colS2Down, i].Value = dt1.Rows[0][lc.lotdb.lot.r2Down].ToString(); //dgvSale[colSUp, i].Value = dt1.Rows[0][lc.lotdb.lot.rUp].ToString(); //dgvSale[colSDown, i].Value = dt1.Rows[0][lc.lotdb.lot.rDown].ToString(); dgvSale[colSId, i].Value = dt.Rows[i][lc.saledb.sale.Id].ToString(); amt += Double.Parse(dt.Rows[i]["amt"].ToString()); reward = Double.Parse(dt1.Rows[0][lc.lotdb.lot.r3Up].ToString()) + Double.Parse(dt1.Rows[0][lc.lotdb.lot.r3Tod].ToString()) + Double.Parse(dt1.Rows[0][lc.lotdb.lot.r3Down].ToString()) + Double.Parse(dt1.Rows[0][lc.lotdb.lot.r2Up].ToString()) + Double.Parse(dt1.Rows[0][lc.lotdb.lot.r2Down].ToString()) + Double.Parse(dt1.Rows[0][lc.lotdb.lot.rUp].ToString()) + Double.Parse(dt1.Rows[0][lc.lotdb.lot.rDown].ToString()); nettotal = Double.Parse(dgvSale[colSAmt, i].Value.ToString()) - Double.Parse(dgvSale[colSPay, i].Value.ToString()) - reward; amt1 += nettotal; amt2 += reward; dgvSale[colSStatusDiscount, i].Value = String.Format("{0:#,###,###.00}", reward); dgvSale[colSPerDiscount, i].Value = String.Format("{0:#,###,###.00}", nettotal); //dgvRate[colRId, i].Value = dt.Rows[i][lc.ratedb.rate.Id].ToString(); if ((i % 2) != 0) { dgvSale.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon; } } } dgvSale.RowHeadersVisible = false; dgvSale.Columns[colSId].Visible = false; //dgvSale.Columns[colSStatusDiscount].Visible = false; //dgvSale.Columns[colSPerDiscount].Visible = false; //dgvSale.Columns[colRRow].Visible = false; dgvSale[colSAmt, dgvSale.RowCount - 1].Value = String.Format("{0:#,###,###.00}", amt); dgvSale[colSPerDiscount, dgvSale.RowCount - 1].Value = String.Format("{0:#,###,###.00}", amt1); dgvSale[colSStatusDiscount, dgvSale.RowCount - 1].Value = String.Format("{0:#,###,###.00}", amt2); dgvSale.Font = font; dgvSale.ReadOnly = true; //setDataGrdThoo(); //setThooAmount(); }