private void frmPersonDetails_Load(object sender, EventArgs e) { //string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 0 AND CFLAG = 0 ORDER BY DOCNO DESC "; string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 1 AND CFLAG = 0 ORDER BY CAST(WORKDATE as date) DESC "; //string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 1 AND BR2 = 1 AND CFLAG = 0 ORDER BY DOCNO DESC "; DataSet ds_DOCNO = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_DOCNO, 1000, true); cmbDOCNO.BeginUpdate(); cmbDOCNO.DataSource = ds_DOCNO.Tables[0]; cmbDOCNO.DisplayMember = "DOCNO"; cmbDOCNO.ValueMember = "DOCNO"; cmbDOCNO.EndUpdate(); lsvData.LabelWrap = false; // Add Columns lsvData.Columns.Add("#", 60, HorizontalAlignment.Right); lsvData.Columns.Add("รหัสสาขา", 80, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อสาขา", 80, HorizontalAlignment.Left); lsvData.Columns.Add("รหัสพนักงาน", 100, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อพนักงาน", 120, HorizontalAlignment.Left); lsvData.Columns.Add("จำนวนบิลขายปกติ", 130, HorizontalAlignment.Left); lsvData.Columns.Add("TOTAL NET", 80, HorizontalAlignment.Left); lsvData.Columns.Add("AVG (NET/Bills)", 130, HorizontalAlignment.Left); lsvData.Columns.Add("จำนวนบิลขายออนไลน์", 150, HorizontalAlignment.Left); lsvData.Columns.Add("TOTAL NET", 80, HorizontalAlignment.Left); lsvData.Columns.Add("AVG (NET/Bills)", 130, HorizontalAlignment.Left); }
private void frmInvoice_Online_Load(object sender, EventArgs e) { string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 0 AND CFLAG = 0 ORDER BY CAST(WORKDATE as date) DESC "; //string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 1 AND BR2 = 0 AND CFLAG = 0 ORDER BY DOCNO DESC "; DataSet ds_DOCNO = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_DOCNO, 1000, true); cmbDOCNO.BeginUpdate(); cmbDOCNO.DataSource = ds_DOCNO.Tables[0]; cmbDOCNO.DisplayMember = "DOCNO"; cmbDOCNO.ValueMember = "DOCNO"; cmbDOCNO.EndUpdate(); string sql_BID = @" SELECT BID,BNAME FROM MAS_BRAND WHERE CFLAG = 0"; DataSet ds_BID = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_BID, 1000, true); cmdBID.BeginUpdate(); cmdBID.DataSource = ds_BID.Tables[0]; cmdBID.DisplayMember = "BNAME"; cmdBID.ValueMember = "BNAME"; cmdBID.EndUpdate(); string sql_TYID = @" SELECT TYID,NAME FROM MAS_TYPE WHERE CFLAG = 0 "; DataSet ds_TYID = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_TYID, 1000, true); cmdTYID.BeginUpdate(); cmdTYID.DataSource = ds_TYID.Tables[0]; cmdTYID.DisplayMember = "NAME"; cmdTYID.ValueMember = "NAME"; cmdTYID.EndUpdate(); lsvData.LabelWrap = false; // Add Columns lsvData.Columns.Add("#", 60, HorizontalAlignment.Right); lsvData.Columns.Add("เลขที่เอกสาร", 120, HorizontalAlignment.Left); lsvData.Columns.Add("เดือน", 80, HorizontalAlignment.Left); lsvData.Columns.Add("ปี", 80, HorizontalAlignment.Left); lsvData.Columns.Add("TYPE", 80, HorizontalAlignment.Left); lsvData.Columns.Add("BRAND", 80, HorizontalAlignment.Left); lsvData.Columns.Add("รหัสสาขา", 80, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อสาขา", 100, HorizontalAlignment.Left); lsvData.Columns.Add("รหัสพนักงาน", 80, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อพนักงาน", 200, HorizontalAlignment.Left); lsvData.Columns.Add("NET", 80, HorizontalAlignment.Left); lsvData.Columns.Add("ADJ", 80, HorizontalAlignment.Left); lsvData.Columns.Add("NET_ADJ", 80, HorizontalAlignment.Left); lsvData.Columns.Add("DVAL", 80, HorizontalAlignment.Left); }
private void Init() { string sql_BID = @" SELECT BID,BNAME FROM MAS_BRAND WHERE CFLAG = 0"; DataSet ds_BID = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_BID, 1000, true); cmdBID.BeginUpdate(); cmdBID.DataSource = ds_BID.Tables[0]; cmdBID.DisplayMember = "BNAME"; cmdBID.ValueMember = "BID"; cmdBID.EndUpdate(); }
private void Init() { string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 0 AND CFLAG = 0 ORDER BY DOCNO DESC "; DataSet ds_DOCNO = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_DOCNO, 1000, true); cmbDOCNO.BeginUpdate(); cmbDOCNO.DataSource = ds_DOCNO.Tables[0]; cmbDOCNO.DisplayMember = "DOCNO"; cmbDOCNO.ValueMember = "DOCNO"; cmbDOCNO.EndUpdate(); }
private void frmCom_RetailReport_Load(object sender, EventArgs e) { string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 1 AND CFLAG = 0 ORDER BY CAST(WORKDATE as date) DESC "; //string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 1 AND BR2 = 1 AND CFLAG = 0 ORDER BY DOCNO DESC "; DataSet ds_DOCNO = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_DOCNO, 1000, true); cmbDOCNO.BeginUpdate(); cmbDOCNO.DataSource = ds_DOCNO.Tables[0]; cmbDOCNO.DisplayMember = "DOCNO"; cmbDOCNO.ValueMember = "DOCNO"; cmbDOCNO.EndUpdate(); lsvData.LabelWrap = false; // Add Columns lsvData.Columns.Add("#", 60, HorizontalAlignment.Right); lsvData.Columns.Add("รหัสสาขา", 100, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อสาขา", 100, HorizontalAlignment.Left); lsvData.Columns.Add("รหัสพนักงาน", 100, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อพนักงาน", 200, HorizontalAlignment.Left); lsvData.Columns.Add("รหัสแอร์เรีย", 100, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อแอร์เรีย", 200, HorizontalAlignment.Left); lsvData.Columns.Add("WHGROUP", 100, HorizontalAlignment.Left); lsvData.Columns.Add("คอมสาขา COM_RETAIL", 120, HorizontalAlignment.Left); lsvData.Columns.Add("ACHIEVE", 120, HorizontalAlignment.Left); lsvData.Columns.Add("ค่ารักษาสินค้า TREATMENT", 120, HorizontalAlignment.Left); lsvData.Columns.Add("ค่าบริหาร SERVICE_CHARGE", 120, HorizontalAlignment.Left); lsvData.Columns.Add("ดูแลสาขา CARE_COSTS", 130, HorizontalAlignment.Left); }
private void SaveData() { string REMARK = "โอนยอดระหว่างสาขา จากสาขา " + _whcode + " ไปยังสาขา " + txtWHCODEnew.Text; _cBeauty._WORKDATE = cDateTime.getDateForSql(); string sql_LOG_ADJ = @"INSERT INTO COMMISSION_LOG_ADJ (DOCNO,[TYPE],BRAND,WHCODE,WHCODE_NEW,STCODE,NET_TOTAL,NET_ADJ,STCODE_LOG,REMARK,WORKEDATE) VALUES (@DOCNO,@TYPE,@BRAND,@WHCODE,@WHCODE_NEW,@STCODE,@NET_TOTAL,@NET_ADJ,@STCODE_LOG,@REMARK,@WORKEDATE)" ; string sql_COM_DOC_I = @"UPDATE COMMISSION_DOC_I SET WHCODE = @WHCODE WHERE ID = @ID AND DOCNO = @DOCNO " ; using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBeautySystem())) { conn.Open(); SqlTransaction sqltrans = null; sqltrans = conn.BeginTransaction(); try { using (SqlCommand comm = new SqlCommand()) { comm.CommandType = CommandType.Text; comm.CommandTimeout = 1000; comm.Connection = conn; comm.Transaction = sqltrans; comm.CommandText = sql_LOG_ADJ; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@DOCNO", txtDOCNO.Text); comm.Parameters.AddWithValue("@TYPE", _TYID); comm.Parameters.AddWithValue("@BRAND", _BID); comm.Parameters.AddWithValue("@WHCODE", _whcode); comm.Parameters.AddWithValue("@WHCODE_NEW", txtWHCODEnew.Text); comm.Parameters.AddWithValue("@STCODE", DBNull.Value); comm.Parameters.AddWithValue("@NET_TOTAL", 0); comm.Parameters.AddWithValue("@NET_ADJ", 0); comm.Parameters.AddWithValue("@STCODE_LOG", _cBeauty._STCODE_LOG); comm.Parameters.AddWithValue("@REMARK", REMARK); comm.Parameters.AddWithValue("@WORKEDATE", _cBeauty._WORKDATE); comm.ExecuteNonQuery(); comm.CommandText = sql_COM_DOC_I; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@ID", _ID); comm.Parameters.AddWithValue("@DOCNO", _docno); comm.Parameters.AddWithValue("@WHCODE", txtWHCODEnew.Text); comm.ExecuteNonQuery(); } sqltrans.Commit(); cMessage.ShowMessage("บันทึกข้อมูลเรียบร้อย"); } catch (Exception ex) { sqltrans.Rollback(); cMessage.Error_NotCaption(ex.Message); } } }
private void GetData() { cMessage.ShowMessage("กรุณารอสักครู่ กำลังดำเนินการ"); string sql = @"SELECT B.BNAME,C.NAME,A.WHCODE,A.WHNAME,A.STCODE,A.FULLNAME,A.ABBNO,A.NET,A.DVAL ,A.TYID,A.BID FROM CHF_COMMISSION_COMONLINE ('" + dtp_StartDate.getDateOnlyForSql() + "','" + dtp_EndDate.getDateOnlyForSql() + "','" + dtp_StartDateFP.getDateOnlyForSql() + "','" + dtp_EndDateFP.getDateOnlyForSql() + "') A"; sql += @" LEFT JOIN MAS_BRAND B ON A.BID=B.BID LEFT JOIN MAS_TYPE C ON A.TYID=C.TYID ORDER BY A.TYID,A.BID,A.WHCODE,A.STCODE" ; DataSet ds = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql, 10000, true); if (ds.Tables[0].Rows.Count <= 0) { cMessage.Error_NoData(); return; } lsvData.AddDataWithDataset(ds, true, true, false); lsvData.SetAlternateColorRow(); }
private void frmLOG_WholeSale_Load(object sender, EventArgs e) { string sql_chanel = @" SELECT TYID, NAME FROM MAS_TYPE WHERE CFLAG = 0 "; DataSet ds_chanel = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_chanel, 1000, true); cmbTYID.BeginUpdate(); cmbTYID.DataSource = ds_chanel.Tables[0]; cmbTYID.DisplayMember = "NAME"; cmbTYID.ValueMember = "TYID"; cmbTYID.EndUpdate(); cmbTYID.SelectedIndex = -1; if (_chack == "IS") { string sql_bid = @" SELECT BID, BNAME FROM MAS_BRAND WHERE CFLAG = 0 "; DataSet ds_bid = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_bid, 1000, true); cmbBID.BeginUpdate(); cmbBID.DataSource = ds_bid.Tables[0]; cmbBID.DisplayMember = "BNAME"; cmbBID.ValueMember = "BID"; cmbBID.EndUpdate(); cmbBID.SelectedIndex = -1; } txtDOCNO.Text = _docno; txtBID.Text = _BID; txtnet.Text = _net; txtTYID.Text = _TYPE_N; txtwhcode.Text = _whcode; txtDVAL.Text = _DVAL; }
private void SaveData() { string REMARK = "CN ลดหนี้"; _cBeauty._WORKDATE = cDateTime.getDateForSql(); double net_adj = double.Parse(txtnet_adj.Text); double netx = double.Parse(txtnet.Text); double sumNET = netx - net_adj; string sql_LOG_ADJ = @"INSERT INTO COMMISSION_LOG_ADJ (DOCNO,[TYPE],BRAND,WHCODE,STCODE,NET_TOTAL,NET_ADJ,STCODE_LOG,REMARK,WORKEDATE) VALUES (@DOCNO,@TYPE,@BRAND,@WHCODE,@STCODE,@NET_TOTAL,@NET_ADJ,@STCODE_LOG,@REMARK,@WORKEDATE)" ; string sql_COM_DOC_I = @"UPDATE COMMISSION_DOC_I SET NET_TOTAL = @NET_TOTAL WHERE ID = @ID AND DOCNO = @DOCNO AND WHCODE = @WHCODE AND STCODE = @STCODE" ; using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBeautySystem())) { conn.Open(); SqlTransaction sqltrans = null; sqltrans = conn.BeginTransaction(); try { using (SqlCommand comm = new SqlCommand()) { comm.CommandType = CommandType.Text; comm.CommandTimeout = 1000; comm.Connection = conn; comm.Transaction = sqltrans; comm.CommandText = sql_LOG_ADJ; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@DOCNO", txtDOCNO.Text); comm.Parameters.AddWithValue("@TYPE", _TYID); comm.Parameters.AddWithValue("@BRAND", _BID); comm.Parameters.AddWithValue("@WHCODE", _whcode); comm.Parameters.AddWithValue("@STCODE", _stcode); comm.Parameters.AddWithValue("@NET_TOTAL", netx); comm.Parameters.AddWithValue("@NET_ADJ", net_adj); comm.Parameters.AddWithValue("@STCODE_LOG", _cBeauty._STCODE_LOG); comm.Parameters.AddWithValue("@REMARK", REMARK); comm.Parameters.AddWithValue("@WORKEDATE", _cBeauty._WORKDATE); comm.ExecuteNonQuery(); comm.CommandText = sql_COM_DOC_I; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@NET_TOTAL", sumNET); comm.Parameters.AddWithValue("@ID", _ID); comm.Parameters.AddWithValue("@DOCNO", _docno); comm.Parameters.AddWithValue("@WHCODE", _whcode); comm.Parameters.AddWithValue("@STCODE", _stcode); comm.ExecuteNonQuery(); } sqltrans.Commit(); cMessage.ShowMessage("บันทึกข้อมูลเรียบร้อย"); } catch (Exception ex) { sqltrans.Rollback(); cMessage.Error_NotCaption(ex.Message); } } }
private void SaveData() { string sql_com = "SELECT * FROM COMMISSION_TAGET "; DataSet ds_com = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_com, 10000, true); if (ds_com.Tables[0].Rows.Count > 0) { string sql_UPDATE = "TRUNCATE TABLE COMMISSION_TAGET "; cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_UPDATE, 10000, true); } //string sql = "INSERT INTO COMMISSION_TAGET (WHCODE,TAGET,WORKDATE,CFLAG) VALUES (@WHCODE,@TAGET,@WORKDATE,@CFLAG)"; string sql = @"INSERT INTO COMMISSION_TAGET (WHCODE,TAGET,WORKDATE,DOCNO,ComOnline_Net_whcode,ComOnline_Net_stcode,WORKDATE_ComOnline,CFLAG) VALUES (@WHCODE,@TAGET,@WORKDATE,@DOCNO,@ComOnline_Net_whcode,@ComOnline_Net_stcode,@WORKDATE_ComOnline,@CFLAG)" ; string WHCODE; string TAGET; string WORKDATE = cDateTime.GetDateTimeForSql(); if (lsvData.Items.Count <= 0) { return; } using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBeautySystem())) { conn.Open(); SqlTransaction sqltrans = null; sqltrans = conn.BeginTransaction(); try { using (SqlCommand comm = new SqlCommand()) { comm.CommandType = CommandType.Text; comm.CommandTimeout = 1000; comm.Connection = conn; comm.Transaction = sqltrans; comm.CommandText = sql; for (int i = 0; i < lsvData.Items.Count; i++) { WHCODE = lsvData.Items[i].SubItems[1].Text; TAGET = lsvData.Items[i].SubItems[2].Text; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@WHCODE", WHCODE); comm.Parameters.AddWithValue("@TAGET", TAGET); comm.Parameters.AddWithValue("@WORKDATE", WORKDATE); comm.Parameters.AddWithValue("@DOCNO", DBNull.Value); comm.Parameters.AddWithValue("@ComOnline_Net_stcode", DBNull.Value); comm.Parameters.AddWithValue("@ComOnline_Net_whcode", DBNull.Value); comm.Parameters.AddWithValue("@WORKDATE_ComOnline", DBNull.Value); comm.Parameters.AddWithValue("@CFLAG", 0); comm.ExecuteNonQuery(); } } sqltrans.Commit(); cMessage.Complete_SaveData(); this.Close(); } catch (Exception ex) { sqltrans.Rollback(); cMessage.Error_NotCaption(ex.Message); } } }
private void SaveData() { _DVALnew = txtDVAL.Text; _CFLAGnew = txtCFLAG.Text; if (_DVAL != _DVALnew && _CFLAG != _CFLAGnew) { REMARK = _DVAL + " เปลี่ยนเป็น " + _DVALnew + " และ " + _CFLAG + " เปลี่ยนเป็น " + _CFLAGnew; } else if (_DVAL != _DVALnew) { REMARK = _DVAL + " เปลี่ยนเป็น " + _DVALnew; } else if (_CFLAGnew != _CFLAG) { REMARK = _CFLAG + " เปลี่ยนเป็น " + _CFLAGnew; } _cBeauty._WORKDATE = cDateTime.getDateForSql(); string sql_LOG_ADJ = @"INSERT INTO COMMISSION_LOG_WholeSale (BRAND,PRCODE,DVAL,STCODE_LOG,REMARK,WORKEDATE) VALUES (@BRAND,@PRCODE,@DVAL,@STCODE_LOG,@REMARK,@WORKEDATE)" ; string sql_COM_PR = @"UPDATE COMMISSION_RATE SET DVAL = @DVAL, CFLAG = @CFLAG WHERE BRAND = @BRAND AND ID = @ID" ; using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBeautySystem())) { conn.Open(); SqlTransaction sqltrans = null; sqltrans = conn.BeginTransaction(); try { using (SqlCommand comm = new SqlCommand()) { comm.CommandType = CommandType.Text; comm.CommandTimeout = 1000; comm.Connection = conn; comm.Transaction = sqltrans; comm.CommandText = sql_COM_PR; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@DVAL", _DVALnew); comm.Parameters.AddWithValue("@CFLAG", _CFLAGnew); comm.Parameters.AddWithValue("@BRAND", _BID); comm.Parameters.AddWithValue("@ID", _ID); comm.ExecuteNonQuery(); comm.CommandText = sql_LOG_ADJ; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@BRAND", _BID); comm.Parameters.AddWithValue("@DVAL", _DVALnew); comm.Parameters.AddWithValue("@PRCODE", _PRCODE); comm.Parameters.AddWithValue("@STCODE_LOG", _cBeauty._STCODE_LOG); comm.Parameters.AddWithValue("@REMARK", REMARK); comm.Parameters.AddWithValue("@WORKEDATE", _cBeauty._WORKDATE); comm.ExecuteNonQuery(); } sqltrans.Commit(); cMessage.ShowMessage("บันทึกข้อมูลเรียบร้อย"); this.Close(); } catch (Exception ex) { sqltrans.Rollback(); cMessage.Error_NotCaption(ex.Message); } } }
private void SaveData() { string sql_com = "SELECT * FROM COMMISSION_STCODE_numDAY "; DataSet ds_com = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_com, 10000, true); if (ds_com.Tables[0].Rows.Count > 0) { string sql_s = "TRUNCATE TABLE COMMISSION_STCODE_numDAY "; //string sql_UPDATE = "UPDATE COMMISSION_STCODE_numDAY SET CFLAG = 1 "; cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_s, 10000, true); } string sql = "INSERT INTO COMMISSION_STCODE_numDAY (WHCODE,STCODE,numDAT,WORKDATE,DOCNO,amount_DAYs,ComOnline_Net,Difference,WORKDATE_ComOnline,CFLAG,ID_Position) " + "VALUES (@WHCODE,@STCODE,@numDAT,@WORKDATE,@DOCNO,@amount_DAYs,@ComOnline_Net,@Difference,@WORKDATE_ComOnline,@CFLAG,@ID_Position)"; string WORKDATE = cDateTime.GetDateTimeForSql(); if (lsvData.Items.Count <= 0) { return; } using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBeautySystem())) { conn.Open(); SqlTransaction sqltrans = null; sqltrans = conn.BeginTransaction(); try { using (SqlCommand comm = new SqlCommand()) { comm.CommandType = CommandType.Text; comm.CommandTimeout = 1000; comm.Connection = conn; comm.Transaction = sqltrans; comm.CommandText = sql; for (int i = 0; i < lsvData.Items.Count; i++) { string WHCODE = lsvData.Items[i].SubItems[1].Text; string STCODE = lsvData.Items[i].SubItems[2].Text; string ID_Position = lsvData.Items[i].SubItems[3].Text; string start_date = lsvData.Items[i].SubItems[4].Text; string end_date = lsvData.Items[i].SubItems[5].Text; GETDATE(start_date, end_date); comm.Parameters.Clear(); comm.Parameters.AddWithValue("@WHCODE", WHCODE); comm.Parameters.AddWithValue("@STCODE", STCODE); comm.Parameters.AddWithValue("@numDAT", numDAT); comm.Parameters.AddWithValue("@WORKDATE", WORKDATE); comm.Parameters.AddWithValue("@DOCNO", DBNull.Value); comm.Parameters.AddWithValue("@amount_DAYs", DBNull.Value); comm.Parameters.AddWithValue("@ComOnline_Net", DBNull.Value); comm.Parameters.AddWithValue("@Difference", DBNull.Value); comm.Parameters.AddWithValue("@WORKDATE_ComOnline", DBNull.Value); comm.Parameters.AddWithValue("@CFLAG", 0); comm.Parameters.AddWithValue("@ID_Position", ID_Position); comm.ExecuteNonQuery(); } } sqltrans.Commit(); cMessage.Complete_SaveData(); this.Close(); } catch (Exception ex) { sqltrans.Rollback(); cMessage.Error_NotCaption(ex.Message); } } }
private void SaveData() { string sql_com = "SELECT * FROM COMMISSION_TAGET_RETAIL "; DataSet ds_com = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_com, 10000, true); if (ds_com.Tables[0].Rows.Count > 0) { string sql_UPDATE = "TRUNCATE TABLE COMMISSION_TAGET_RETAIL "; cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_UPDATE, 10000, true); } string sql = @"INSERT INTO COMMISSION_TAGET_RETAIL (WHCODE,STCODE_area,WHGROUP,TARGET,NET,TARGET_WS,NET_WS,SHOPCARE,WORKDATE,CFLAG) VALUES (@WHCODE,@STCODE_area,@WHGROUP,@TARGET,@NET,@TARGET_WS,@NET_WS,@SHOPCARE,@WORKDATE,@CFLAG)" ; if (lsvData.Items.Count <= 0) { return; } using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBeautySystem())) { conn.Open(); SqlTransaction sqltrans = null; sqltrans = conn.BeginTransaction(); try { using (SqlCommand comm = new SqlCommand()) { comm.CommandType = CommandType.Text; comm.CommandTimeout = 1000; comm.Connection = conn; comm.Transaction = sqltrans; comm.CommandText = sql; for (int i = 0; i < lsvData.Items.Count; i++) { string WHCODE = lsvData.Items[i].SubItems[1].Text; string STCODE_area = lsvData.Items[i].SubItems[2].Text; string WHGROUP = lsvData.Items[i].SubItems[3].Text; string TARGET = lsvData.Items[i].SubItems[4].Text; string NET = lsvData.Items[i].SubItems[5].Text; string TARGET_WS = lsvData.Items[i].SubItems[6].Text; string NET_WS = lsvData.Items[i].SubItems[7].Text; string SHOPCARE = lsvData.Items[i].SubItems[8].Text; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@WHCODE", WHCODE); comm.Parameters.AddWithValue("@STCODE_area", STCODE_area); comm.Parameters.AddWithValue("@WHGROUP", WHGROUP); comm.Parameters.AddWithValue("@TARGET", TARGET); comm.Parameters.AddWithValue("@NET", NET); comm.Parameters.AddWithValue("@TARGET_WS", TARGET_WS); comm.Parameters.AddWithValue("@NET_WS", NET_WS); comm.Parameters.AddWithValue("@SHOPCARE", SHOPCARE); comm.Parameters.AddWithValue("@WORKDATE", cDateTime.GetDateTimeForSql()); comm.Parameters.AddWithValue("@CFLAG", 0); comm.ExecuteNonQuery(); } } sqltrans.Commit(); cMessage.Complete_SaveData(); this.Close(); } catch (Exception ex) { sqltrans.Rollback(); cMessage.Error_NotCaption(ex.Message); } } }
private void frmCom_OnlineReport_Load(object sender, EventArgs e) { string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 1 AND CFLAG = 0 ORDER BY CAST(WORKDATE as date) DESC "; //string sql_DOCNO = @" SELECT DOCNO FROM COMMISSION_DOC WHERE IT = 1 AND BR = 1 AND BR2 = 1 AND CFLAG = 0 ORDER BY DOCNO DESC "; DataSet ds_DOCNO = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_DOCNO, 1000, true); cmbDOCNO.BeginUpdate(); cmbDOCNO.DataSource = ds_DOCNO.Tables[0]; cmbDOCNO.DisplayMember = "DOCNO"; cmbDOCNO.ValueMember = "DOCNO"; cmbDOCNO.EndUpdate(); lsvData.LabelWrap = false; // Add Columns lsvData.Columns.Add("#", 60, HorizontalAlignment.Right); lsvData.Columns.Add("รหัสสาขา", 100, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อสาขา", 200, HorizontalAlignment.Left); lsvData.Columns.Add("รหัสพนักงาน", 100, HorizontalAlignment.Left); lsvData.Columns.Add("ชื่อพนักงาน", 200, HorizontalAlignment.Left); lsvData.Columns.Add("TAGET", 120, HorizontalAlignment.Left); lsvData.Columns.Add("ยอดขายสาขา", 120, HorizontalAlignment.Left); lsvData.Columns.Add("% Ach Online", 120, HorizontalAlignment.Left); lsvData.Columns.Add("จำนวนวันทำงาน", 120, HorizontalAlignment.Left); lsvData.Columns.Add("Com Online", 130, HorizontalAlignment.Left); }