public String saveThoo(Thoo p) { String chk = ""; chk = thodb.insertThoo(p); return(chk); }
public List <Thoo> setData() { List <Thoo> ltho = new List <Thoo>(); Thoo t = new Thoo(); DataTable dt = selectAll(); for (int i = 0; i < dt.Rows.Count; i++) { //t = thodb.setData(t, dt, i); t = new Thoo(); t.Id = dt.Rows[i][tho.Id].ToString(); t.Code = dt.Rows[i][tho.Code].ToString(); t.Name = dt.Rows[i][tho.Name].ToString(); t.Remark = dt.Rows[i][tho.Remark].ToString(); t.Active = dt.Rows[i][tho.Active].ToString(); t.Color = dt.Rows[i][tho.Color].ToString(); t.Limit1 = dt.Rows[i][tho.Limit1].ToString(); t.Default = dt.Rows[i][tho.Default].ToString(); t.dateModiThooDefault = dt.Rows[0][tho.dateModiThooDefault].ToString(); t.staffModiThooDefault = dt.Rows[0][tho.staffModiThooDefault].ToString(); t.thooDefaultCnt = dt.Rows[0][tho.thooDefaultCnt].ToString(); ltho.Add(t); } return(ltho); }
public String UpdateThooDefault(String thooId, String sfId) { Thoo item = new Thoo(); String sql = "", chk = ""; if (thooId == null) { return(""); } if (thooId.Equals("")) { return(""); } item = selectByPk(thooId); if (item.Id.Equals("")) { return(""); } sql = "Update " + tho.table + " Set " + tho.Default + "='0' "; chk = conn.ExecuteNonQuery(sql); sql = "Update " + tho.table + " Set " + tho.Default + "='1', " + tho.staffModiThooDefault + "='" + sfId + "', " + tho.dateModiThooDefault + "=" + tho.dateGenDB + ", " + tho.thooDefaultCnt + "=" + tho.thooDefaultCnt + "+1 " + "Where " + tho.pkField + "='" + thooId + "'"; chk = conn.ExecuteNonQuery(sql); return(chk); }
private String update(Thoo p) { String sql = "", chk = ""; p.Name = p.Name.Replace("''", "'"); sql = "Update " + tho.table + " Set " + tho.Name + "='" + p.Name + "', " + tho.Remark + "='" + p.Remark + "', " + tho.Code + "='" + p.Code + "', " + tho.Limit1 + "=" + p.Limit1 + ", " + tho.Color + "='" + p.Color + "' " + //tho.Default + "='" + p.Default + "' " + "Where " + tho.pkField + "='" + p.Id + "'"; try { chk = conn.ExecuteNonQuery(sql); } catch (Exception ex) { MessageBox.Show("Error " + ex.ToString(), "update Thoodb"); } finally { } return(chk); }
private String insert(Thoo p) { String sql = "", chk = ""; if (p.Id.Equals("")) { p.Id = p.getGenID(); p.Color = selectMax(); } p.Name = p.Name.Replace("''", "'"); p.Remark = p.Remark.Replace("''", "'"); sql = "Insert Into " + tho.table + " (" + tho.pkField + "," + tho.Name + "," + tho.Remark + "," + tho.Active + "," + tho.Code + "," + tho.Limit1 + "," + tho.Color + "," + tho.Default + "," + tho.thooDefaultCnt + "," + tho.staffModiThooDefault + "," + tho.dateModiThooDefault + ") " + "Values('" + p.Id + "','" + p.Name + "','" + p.Remark + "','" + p.Active + "','" + p.Code + "'," + p.Limit1 + "," + p.Color + ",'0',0,'','')"; try { chk = conn.ExecuteNonQuery(sql); chk = p.Id; } catch (Exception ex) { MessageBox.Show("Error " + ex.ToString(), "insert Thoodb"); } finally { } return(chk); }
private void btnSave_Click(object sender, EventArgs e) { if (txtThooName.Text.Equals("")) { MessageBox.Show("aaa", "aaa"); return; } if (txtThooCode.Text.Equals("")) { MessageBox.Show("aaa", "aaa"); return; } if (txtThooId.Text.Equals("")) { tho = lc.thodb.selectByCode(txtThooCode.Text); if (!tho.Code.Equals("")) { MessageBox.Show("aaaa", "aaaa"); return; } } tho = getControl(); //color = tho.Color; if (lc.saveThoo(tho).Length >= 1) { MessageBox.Show("บันทึกข้อมูล เรียบร้อย", "บันทึกข้อมูล"); this.Dispose(); //this.Hide(); } }
private void initConfig(String sfCode, String thooTranferId) { ComboBoxItem cbo = new ComboBoxItem(); String monthId = ""; lc = new LottoryControl(); sf = lc.sfdb.selectByCode(sfCode); thoD = lc.thodb.selectByDefault(); thoTranfer = lc.thodb.selectByPk(thooTranferId); cbo.Value = thoTranfer.Id; cbo.Text = thoTranfer.Name; cboThoo = lc.thodb.getCboThoo(cboThoo); cboThoo.SelectedItem = cboThoo; cboThoo.Text = thoTranfer.Name; monthId = System.DateTime.Now.Month.ToString("00"); if ((System.DateTime.Now.Day >= 2) && (System.DateTime.Now.Day <= 17)) { cboPeriod.SelectedValue = "02"; } else { cboPeriod.SelectedValue = "01"; } cboMonth = lc.cf.setCboMonth(cboMonth); cboPeriod = lc.cf.setCboPeriod(cboPeriod); //cboStaff = lc.sfdb.getCboStaff(cboStaff); cboMonth.SelectedValue = monthId; cboYear = lc.cf.setCboYear(cboYear); setHGrdLotto(); setDGrdLotto(); }
private void initConfig(String sfCode) { lc = new LottoryControl(); tho = lc.thodb.selectByDefault(); sf = lc.sfdb.selectByCode(sfCode); cboThoo = lc.thodb.getCboThooAll(cboThoo); //ComboBoxItem cbo = new ComboBoxItem(); //cbo.Value = tho.Id; //cbo.Text = tho.Name; cboThoo.Text = tho.Name; }
public Thoo getThoo(String thoId) { Thoo i = new Thoo(); foreach (Thoo t in lTho) { if (t.Id.Equals(thoId)) { return(t); } } return(i); }
public Thoo selectByDefault() { Thoo item = new Thoo(); String sql = ""; DataTable dt = new DataTable(); sql = "Select * From " + tho.table + " Where " + tho.Default + "='1'"; dt = conn.selectData(sql); if (dt.Rows.Count > 0) { item = setData(item, dt); } return(item); }
public Thoo selectByCode(String saleId) { Thoo item = new Thoo(); String sql = ""; DataTable dt = new DataTable(); sql = "Select * From " + tho.table + " Where " + tho.Code + "='" + saleId + "' and " + tho.Active + "='1' "; dt = conn.selectData(sql); if (dt.Rows.Count > 0) { item = setData(item, dt); } return(item); }
private Thoo setData(Thoo item, DataTable dt) { item.Id = dt.Rows[0][tho.Id].ToString(); item.Code = dt.Rows[0][tho.Code].ToString(); item.Name = dt.Rows[0][tho.Name].ToString(); item.Remark = dt.Rows[0][tho.Remark].ToString(); item.Active = dt.Rows[0][tho.Active].ToString(); item.Color = dt.Rows[0][tho.Color].ToString(); item.Limit1 = dt.Rows[0][tho.Limit1].ToString(); item.Default = dt.Rows[0][tho.Default].ToString(); item.dateModiThooDefault = dt.Rows[0][tho.dateModiThooDefault].ToString(); item.staffModiThooDefault = dt.Rows[0][tho.staffModiThooDefault].ToString(); item.thooDefaultCnt = dt.Rows[0][tho.thooDefaultCnt].ToString(); return(item); }
private void initConfig(String sfCode, LottoryControl l, Boolean statuscheck, Boolean statuscheck2) { pB1.Visible = false; StatusCheck = statuscheck; // เอาไว้ check ว่ามาจากหน้าจอ Input หรือ หน้าจอ Check StatusCheck2 = statuscheck2; // เอาไว้ check ว่ามาจากหน้าจอ Input หรือ หน้าจอ Check if (StatusCheck) { this.Text = "ตรวจสอบ ป้อนข้อมูลจากรูป"; } else { this.Text = "ป้อนข้อมูลจากรูป"; } img = new Image1(); String monthId = "", periodId = ""; lc = l; sf = lc.sfdb.selectByCode(sfCode); tho = lc.thodb.selectByDefault(); monthId = System.DateTime.Now.Month.ToString("00"); cboMonth = lc.cf.setCboMonth(cboMonth); cboPeriod = lc.cf.setCboPeriod(cboPeriod); cboStaff = lc.sfdb.getCboStaff(cboStaff); cboSale = lc.saledb.getCboSale(cboSale); cboSale1 = cboSale; cboThoo = lc.thodb.getCboThoo(cboThoo); cboMonth.SelectedValue = monthId; cboYear = lc.cf.setCboYear(cboYear); ComboBoxItem cbo = new ComboBoxItem(); cbo.Value = sf.Id; cbo.Text = sf.Name; cboStaff.Text = sf.Name; cboThoo.Text = tho.Name; cboPeriod = lc.setCboPeriodDefault(cboPeriod); picRotate.Visible = false; picZoomM.Visible = false; picZoomP.Visible = false; picHand.Visible = false; lotNew = true; clearGrd1 = false; setGrid1(); viewImage(); setResize(); btnEdit.Enabled = false; }
public String insertThoo(Thoo p) { Thoo item = new Thoo(); String chk = ""; item = selectByPk(p.Id); if (item.Id == "") { chk = insert(p); } else { chk = update(p); } return(chk); }
private void setGrd1() { double up = 0, tod = 0, down = 0, amt = 0; DataTable dt = new DataTable(); dgv1.Rows.Clear(); //Color c = new Color(); dgv1.Visible = false; Thoo t = new Thoo(); dt = lc.lotdb.selectByPeriod(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString()); if (dt.Rows.Count > 0) { dgv1.RowCount = dt.Rows.Count; for (int i = 0; i < dt.Rows.Count; i++) { try { setDataGrid1(dgv1, i, dt.Rows[i][lc.lotdb.lot.number].ToString(), Double.Parse(dt.Rows[i][lc.lotdb.lot.up].ToString()), Double.Parse(dt.Rows[i][lc.lotdb.lot.tod].ToString()), Double.Parse(dt.Rows[i][lc.lotdb.lot.down].ToString()), dt.Rows[i][lc.lotdb.lot.rowId].ToString(), dt.Rows[i][lc.lotdb.lot.lottoId].ToString(), "", "", "", "", "", dt.Rows[i][lc.lotdb.lot.thooTranferId].ToString()); up += Double.Parse(lc.cf.NumberNull(dt.Rows[i][lc.lotdb.lot.up])); tod += Double.Parse(lc.cf.NumberNull(dt.Rows[i][lc.lotdb.lot.tod])); down += Double.Parse(lc.cf.NumberNull(dt.Rows[i][lc.lotdb.lot.down])); //amt += up + tod + down; t = lc.getThoo(dt.Rows[i][lc.lotdb.lot.thooTranferId].ToString()); //c = ColorTranslator.FromHtml(t.Color); dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml(lc.getThooBackColor(t.Color)); } catch (Exception ex) { } } } txtUp.Text = String.Format("{0:#,###,###.00}", up); txtTod.Text = String.Format("{0:#,###,###.00}", tod); txtDown.Text = String.Format("{0:#,###,###.00}", down); txtAmt.Text = String.Format("{0:#,###,###.00}", (up + tod + down)); dgv1.Visible = true; setApprove(); setThooAmount(); setRateAmount(); }
private void initConfig() { tho = new Thoo(); tho.Id = "thoo_id"; tho.Code = "thoo_code"; tho.Name = "thoo_name"; tho.Remark = "thoo_remark"; tho.Active = "thoo_active"; tho.Color = "thoo_color"; tho.Limit1 = "thoo_limit"; tho.Default = "thoo_default"; tho.dateModiThooDefault = "date_modi_thoo_default"; tho.staffModiThooDefault = "staff_modi_thoo_default"; tho.thooDefaultCnt = "thoo_default_cnt"; tho.sited = ""; tho.table = "b_thoo"; tho.pkField = "thoo_id"; }
private void initConfig(String sfCode, LottoryControl l) { String monthId = "", periodId = ""; //cf = new Config1(); //lc = new LottoryControl(); lc = l; sf = lc.sfdb.selectByCode(sfCode); tho = lc.thodb.selectByDefault(); //lc.sfdb.sf = sf; monthId = System.DateTime.Now.Month.ToString("00"); setGrid1(); setGridLotto(1); //setGrid2(); //setGrid3(); cboMonth = lc.cf.setCboMonth(cboMonth); cboPeriod = lc.cf.setCboPeriod(cboPeriod); cboStaff = lc.sfdb.getCboStaff(cboStaff); cboSale = lc.saledb.getCboSale(cboSale); cboSale1 = cboSale; cboThoo = lc.thodb.getCboThoo(cboThoo); cboMonth.SelectedValue = monthId; cboYear = lc.cf.setCboYear(cboYear); ComboBoxItem cbo = new ComboBoxItem(); cbo.Value = sf.Id; cbo.Text = sf.Name; cboStaff.Text = sf.Name; cboThoo.Text = tho.Name; lotNew = true; clearGrd1 = false; btnEdit.Enabled = false; btnEditColor = btnEdit.BackColor; cboPeriod = lc.setCboPeriodDefault(cboPeriod); setGridLot(); label18.Text = ""; }
private void initConfig(String sfCode, LottoryControl l) { pB1.Visible = false; img = new Image1(); String monthId = "", periodId = ""; lc = l; sf = lc.sfdb.selectByCode(sfCode); tho = lc.thodb.selectByDefault(); monthId = System.DateTime.Now.Month.ToString("00"); cboMonth = lc.cf.setCboMonth(cboMonth); cboPeriod = lc.cf.setCboPeriod(cboPeriod); cboStaff = lc.sfdb.getCboStaff(cboStaff); cboSale = lc.saledb.getCboSale(cboSale); cboSaleNew = lc.saledb.getCboSale(cboSaleNew); cboSale1 = cboSale; cboThoo = lc.thodb.getCboThoo(cboThoo); cboMonth.SelectedValue = monthId; cboYear = lc.cf.setCboYear(cboYear); ComboBoxItem cbo = new ComboBoxItem(); cbo.Value = sf.Id; cbo.Text = sf.Name; cboStaff.Text = sf.Name; cboThoo.Text = tho.Name; cboPeriod = lc.setCboPeriodDefault(cboPeriod); picRotate.Visible = false; picZoomM.Visible = false; picZoomP.Visible = false; picHand.Visible = false; lotNew = true; clearGrd1 = false; setGrid1(); viewImage(); btnEdit.Enabled = false; }
public void setControl(String sfId) { tho = lc.selectThoobyPk(sfId); txtThooId.Text = tho.Id; txtThooCode.Text = tho.Code; txtThooName.Text = tho.Name; txtThooRemark.Text = tho.Remark; txtColor.Text = tho.Color; try { txtColor.BackColor = ColorTranslator.FromHtml(lc.getThooBackColor(tho.Color)); } catch (Exception ex) { } if (tho.Limit1.Equals("")) { txtLimit.Text = "1,000,000"; } else { txtLimit.Text = String.Format("{0:#,###,###.00}", Double.Parse(tho.Limit1)); } if (tho.Active.Equals("1") || sfId.Equals("")) { chkActive.Checked = true; ChkUnActive.Checked = false; btnUnActive.Visible = false; } else { chkActive.Checked = false; ChkUnActive.Checked = true; } }
private void initConfig() { iniFile = new IniFile(Environment.CurrentDirectory + "\\" + Application.ProductName + ".ini"); initC = new InitConfig(); //regE = new RegEdit(); //MessageBox.Show("aaa " + Environment.CurrentDirectory + "\\" + Application.ProductName + ".ini", "LottoryControl StatusServer" + initC.StatusServer.ToLower()); GetConfig(); //MessageBox.Show("bbb", "LottoryControl"); cf = new Config1(); //MessageBox.Show("ccc", "LottoryControl"); conn = new ConnectDB(initC); ratedb = new RateDB(conn); saledb = new SaleDB(conn); sfdb = new StaffDB(conn); thodb = new ThooDB(conn); lotdb = new LottoDB(conn); rwdb = new RewardDB(conn); fldb = new FlockDB(conn); srdb = new SaleRateDB(conn); cudb = new CustomerDB(conn); imgdb = new ImageDB(conn); nldb = new NumberLimitDB(conn); //MessageBox.Show("ddd", "LottoryControl"); rate = new Rate(); sale = new Sale(); staff = new Staff(); tho = new Thoo(); lot = new Lotto(); rw = new Reward(); fl = new FLock(); sr = new SaleRate(); cu = new Customer(); img = new Image1(); nl = new NumberLimit(); r2Down = new Rate(); r2Tod = new Rate(); r2Up = new Rate(); r3Up = new Rate(); r3Tod = new Rate(); r3Down = new Rate(); rUp = new Rate(); rDown = new Rate(); //MessageBox.Show("bbb", "LottoryControl"); rUp = ratedb.selectByPk("up"); rDown = ratedb.selectByPk("down"); r3Up = ratedb.selectByPk("3up"); r3Tod = ratedb.selectByPk("3tod"); r3Down = ratedb.selectByPk("3down"); r2Down = ratedb.selectByPk("2down"); r2Up = ratedb.selectByPk("2up"); lTho = thodb.setData(); setThoColor(); lsr = srdb.selectSRAll(); ls = saledb.selectSAll(); lnl = selectByNumberLimit(); //cboThoo = new ComboBox(); cbosf = new ComboBox(); //cboSale = new ComboBox(); //cboThoo = thodb.getCboThoo(cboThoo); cbosf = sfdb.getCboStaff(cbosf); //cboSale = saledb.getCboSale(cboSale); }
public Thoo selectThoobyPk(String thoId) { tho = thodb.selectByPk(thoId); return(tho); }
private void setGrd2() { Font font = new Font("Microsoft Sans Serif", 12, FontStyle.Bold); Font fontStrike = new Font("Microsoft Sans Serif", 12, FontStyle.Strikeout); double up = 0, tod = 0, down = 0, amt = 0; DataTable dt = new DataTable(); Thoo t = new Thoo(); dt = lc.lotdb.selectApprovedByPeriod(cboYear.Text, cboMonth.SelectedValue.ToString(), cboPeriod.SelectedValue.ToString()); if (dt.Rows.Count > 0) { dgv1.RowCount = dt.Rows.Count; for (int i = 0; i < dt.Rows.Count; i++) { try { setDataGrid1(dgv1, i, dt.Rows[i][lc.lotdb.lot.number].ToString(), Double.Parse(dt.Rows[i][lc.lotdb.lot.up].ToString()), Double.Parse(dt.Rows[i][lc.lotdb.lot.tod].ToString()), Double.Parse(dt.Rows[i][lc.lotdb.lot.down].ToString()), dt.Rows[i][lc.lotdb.lot.rowId].ToString(), dt.Rows[i][lc.lotdb.lot.lottoId].ToString(), dt.Rows[i][lc.lotdb.lot.use1].ToString(), dt.Rows[i][lc.lotdb.lot.statusOverLimit].ToString(), dt.Rows[i][lc.lotdb.lot.OLUp].ToString(), dt.Rows[i][lc.lotdb.lot.OLTod].ToString(), dt.Rows[i][lc.lotdb.lot.OLDown].ToString(), dt.Rows[i][lc.lotdb.lot.thooTranferId].ToString()); up += Double.Parse(lc.cf.NumberNull(dt.Rows[i][lc.lotdb.lot.up])); tod += Double.Parse(lc.cf.NumberNull(dt.Rows[i][lc.lotdb.lot.tod])); down += Double.Parse(lc.cf.NumberNull(dt.Rows[i][lc.lotdb.lot.down])); //amt += up + tod + down; t = lc.getThoo(dt.Rows[i][lc.lotdb.lot.thooTranferId].ToString()); if (dgv1[colThooTranferId, i].Value.ToString().Length > 0) { dgv1.Rows[i].DefaultCellStyle.Font = fontStrike; } if (dgv1[colStatusOL, i].Value.ToString().Equals("1")) { dgv1[colOLUp, i].Style.Font = font; dgv1[colOLUp, i].Style.ForeColor = Color.Red; dgv1[colOLTod, i].Style.Font = font; dgv1[colOLTod, i].Style.ForeColor = Color.Red; dgv1[colOLDown, i].Style.Font = font; dgv1[colOLDown, i].Style.ForeColor = Color.Red; } if (dgv1[colNumber, i].Value.ToString().Length == 1) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#174e75"); } else if (dgv1[colNumber, i].Value.ToString().Length == 2) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#789640"); } else if (dgv1[colNumber, i].Value.ToString().Length == 3) { dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#788540"); } //c = ColorTranslator.FromHtml(t.Color); //dgv1.Rows[i].DefaultCellStyle.BackColor = ColorTranslator.FromHtml(lc.getThooBackColor(t.Color)); } catch (Exception ex) { } } } txtUp.Text = String.Format("{0:#,###,###.00}", up); txtTod.Text = String.Format("{0:#,###,###.00}", tod); txtDown.Text = String.Format("{0:#,###,###.00}", down); txtAmt.Text = String.Format("{0:#,###,###.00}", (up + tod + down)); setThooAmount(); setRateAmount(); }
private void initConfig() { lc = new LottoryControl(); tho = new Thoo(); }