private void ShowData() { try { string sqlTmp = ""; sqlTmp = "SELECT * FROM tbEvidence"; DataSet Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; SqlCommand cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); SqlDataAdapter da = new SqlDataAdapter(cmd); tblEvidence.Clear(); da.Fill(tblEvidence, "tbEvidence"); da.Dispose(); dgvEvidenceList.DataSource = tblEvidence.tbEvidence; //dgvEvidenceList.bi = tblEvidence.tbEvidence; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } SelectRowIndex = -1; }
private void DoLoadData(string UserID) { #region tbUser try { string sqlTmp = ""; sqlTmp = "SELECT * FROM tbUser WHERE UserID = '" + UserID + "'"; DataSet Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; dbConString.Com.Parameters.Clear(); dbConString.Com.Parameters.Add("@UserID", SqlDbType.VarChar).Value = UserID; SqlCommand cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); SqlDataAdapter da = new SqlDataAdapter(cmd); tblUser.Clear(); da.Fill(tblUser, "tbUser"); da.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } #endregion if (tblUser.tbUser.Rows.Count > 0) { UserID = tblUser.tbUser[0].UserID; txtUserName.Text = tblUser.tbUser[0].UserName; txtPassword.Text = tblUser.tbUser[0].Password; txtDetail.Text = tblUser.tbUser[0].Detail; txtConfirm.Text = string.Empty; } }
private void dgvTimeLandHD_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex > -1) { if (dgvTimeLandHD.Rows[e.RowIndex].Cells[colTimeLineHDID.Name].Value != null) { ApplicationDS.tbTimeLineDTRow[] drTempSave = (ApplicationDS.tbTimeLineDTRow[])tdsTempDT.tbTimeLineDT.Select(""); if (drTempSave.Length > 0) { foreach (ApplicationDS.tbTimeLineDTRow drChk in drTempSave) { ApplicationDS.tbTimeLineDTRow[] drTempChk = (ApplicationDS.tbTimeLineDTRow[])tdsTempDTMain.tbTimeLineDT.Select("TimeLineDTID = '" + drChk.TimeLineDTID + "'"); if (drTempChk.Length == 0) { tdsTempDTMain.tbTimeLineDT.ImportRow(drChk); } } } tdsTempDT.Clear(); TempTimeLineHDID = dgvTimeLandHD.Rows[e.RowIndex].Cells[colTimeLineHDID.Name].Value.ToString(); if (!string.IsNullOrEmpty(TempTimeLineHDID)) { ApplicationDS.tbTimeLineDTRow[] drTemp = (ApplicationDS.tbTimeLineDTRow[])tdsTempDTMain.tbTimeLineDT.Select("TimeLineHDID = '" + TempTimeLineHDID + "'"); foreach (ApplicationDS.tbTimeLineDTRow dr in drTemp) { tdsTempDT.tbTimeLineDT.ImportRow(dr); } dgvTimeLandDT.DataSource = tdsTempDT.tbTimeLineDT; } } } }
protected override void DoSearch() { string Whereclause = string.Empty; if (!string.IsNullOrEmpty(tsBtuSearch.Text)) { Whereclause = tsBtuSearch.Text; } else { Whereclause = string.Empty; } //,[VillageName] //,[VillageNo] //,[SubDistrict] //,[District] //,[Province] //,[History] //,[Distress] try { string sqlTmp = ""; sqlTmp = "SELECT * FROM tbLand "; if (!string.IsNullOrEmpty(Whereclause)) { sqlTmp += " WHERE VillageName LIKE '%" + Whereclause + "%' OR VillageNo LIKE '%" + Whereclause + "%' OR SubDistrict LIKE '%" + Whereclause + "%' OR District LIKE '%" + Whereclause + "%' OR Province LIKE '%" + Whereclause + "%' "; } sqlTmp += " ORDER BY Province"; DataSet Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; SqlCommand cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); SqlDataAdapter da = new SqlDataAdapter(cmd); tblLand.Clear(); da.Fill(tblLand, "tbLand"); da.Dispose(); dgvLandList.DataSource = tblLand.tbLand; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } SelectRowIndex = -1; }
private void DoLoadData(string EvidenceID) { #region tbUser try { string sqlTmp = ""; sqlTmp = "SELECT * FROM tbEvidence WHERE EvidenceID = '" + EvidenceID + "'"; DataSet Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; dbConString.Com.Parameters.Clear(); SqlCommand cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); SqlDataAdapter da = new SqlDataAdapter(cmd); tblEvidence.Clear(); da.Fill(tblEvidence, "tbEvidence"); da.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } #endregion if (tblEvidence.tbEvidence.Rows.Count > 0) { EvidenceID = tblEvidence.tbEvidence[0].EvidenceID; txtEvidenceCode.Text = tblEvidence.tbEvidence[0].EvidenceCode; txtEvidenceName.Text = tblEvidence.tbEvidence[0].EvidenceName; txtPath.Text = tblEvidence.tbEvidence[0].Path; //cboEvidenceType.Text = tblEvidence.tbEvidence[0].EvidenceType; txtDetail.Text = tblEvidence.tbEvidence[0].Detail; } if (string.IsNullOrEmpty(txtPath.Text)) { btnPerview.Enabled = false; } else { btnPerview.Enabled = true; } }
private void tsLogin_Click(object sender, EventArgs e) { bool IsCheckLogin = false; if (string.IsNullOrEmpty(txtUsername.Text)) { MessageBox.Show("กรุณากรอกรหัสผู้ใช้", dbConString.xMessage, MessageBoxButtons.OK, MessageBoxIcon.Question); txtUsername.Focus(); return; } if (string.IsNullOrEmpty(txtPassword.Text)) { MessageBox.Show("กรุณากรอกรหัสผ่าน", dbConString.xMessage, MessageBoxButtons.OK, MessageBoxIcon.Question); txtUsername.Focus(); return; } if (!IsCheckLogin) { tblLogin = ProfileConfig.Load(); if (tblLogin.DBProfile.Count > 0) { dbConString.ServerName = tblLogin.DBProfile[0].ServerName; dbConString.DBName = tblLogin.DBProfile[0].DataBase; dbConString.Sa = tblLogin.DBProfile[0].DBLogin; dbConString.SaPassword = tblLogin.DBProfile[0].DBPassword; IsCheckLogin = dbConString.CheckOpenConn(); if (!IsCheckLogin) { DBConfig fConfig = new DBConfig(); fConfig.ShowDialog(); IsCheckLogin = dbConString.CheckOpenConn(); txtPassword.Focus(); return; } } else { DBConfig fConfig = new DBConfig(); fConfig.ShowDialog(); IsCheckLogin = dbConString.CheckOpenConn(); txtPassword.Focus(); return; } } if (IsCheckLogin) { try { string sqlTmp = ""; sqlTmp = "SELECT * FROM tbUser WHERE UserName = '******' AND Password = '******' "; DataSet Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; SqlCommand cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); //dr = dbConString.Com.ExecuteReader(); SqlDataAdapter da = new SqlDataAdapter(cmd); tblUser.Clear(); da.Fill(tblUser, "tbUser"); da.Dispose(); if (tblUser.tbUser.Rows.Count > 0) { dbConString.UserID = tblUser.tbUser[0].UserID; this.Close(); } else { MessageBox.Show("รหัสผ่านไม่ถูกต้อง !!", dbConString.xMessage, MessageBoxButtons.OK, MessageBoxIcon.Question); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void DoLoadData(string LandID) { #region ALL Data try { string sqlTmp = ""; sqlTmp = "SELECT * FROM tbLand WHERE LandID = '" + LandID + "'"; DataSet Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; dbConString.Com.Parameters.Clear(); SqlCommand cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); SqlDataAdapter da = new SqlDataAdapter(cmd); tdsLand.Clear(); da.Fill(tdsLand, "tbLand"); da.Dispose(); sqlTmp = ""; sqlTmp = "SELECT * FROM tbTimeLineHD WHERE LandID = '" + LandID + "'"; Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; dbConString.Com.Parameters.Clear(); cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); da = new SqlDataAdapter(cmd); da.Fill(tdsLand, "tbTimeLineHD"); da.Dispose(); sqlTmp = ""; sqlTmp = "SELECT DT.*,EV.EvidenceCode,EV.EvidenceName,EV.EvidenceType,EV.Detail,EV.Path FROM tbTimeLineDT AS DT LEFT JOIN tbTimeLineHD AS HD ON DT.TimeLineHDID = HD.TimeLineHDID LEFT JOIN tbEvidence AS EV ON DT.EvidenceID = EV.EvidenceID WHERE HD.LandID = '" + LandID + "'"; Ds = new DataSet(); dbConString.Com = new SqlCommand(); dbConString.Com.CommandType = CommandType.Text; dbConString.Com.CommandText = sqlTmp; dbConString.Com.Connection = dbConString.mySQLConn; dbConString.Com.Parameters.Clear(); cmd = new SqlCommand(sqlTmp, dbConString.mySQLConn); da = new SqlDataAdapter(cmd); tdsTempDTMain.Clear(); da.Fill(tdsTempDTMain, "tbTimeLineDT"); da.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } #endregion if (tdsLand.tbLand.Rows.Count > 0) { LandID = tdsLand.tbLand[0].LandID; txtVillageName.Text = tdsLand.tbLand[0].VillageName; txtVillageNo.Text = tdsLand.tbLand[0].VillageNo; txtSubDistrict.Text = tdsLand.tbLand[0].SubDistrict; txtDistrict.Text = tdsLand.tbLand[0].District; txtProvince.Text = tdsLand.tbLand[0].Province; txtHistory.Text = tdsLand.tbLand[0].History; txtDistress.Text = tdsLand.tbLand[0].Distress; // dgvTimeLandHD.DataSource = tdsLand.tbTimeLineHD; colTimeLineHDID.Visible = false; } }