private void FillComboBox() { DataTable dt = DBChat.GetAllShareCode(); cmbShareCode.ValueMember = "ID"; cmbShareCode.DisplayMember = "ShareCodeText"; cmbShareCode.DataSource = dt; DataRow dr = dt.NewRow(); dr[1] = "Select All"; dr[0] = 0; dt.Rows.InsertAt(dr, 0); cmbShareCode.SelectedIndex = 0; }
public static string GetChatDBByBuildDate() { StringBuilder str = new StringBuilder(); DBManager db = new DBManager("odbc"); db.Open(); DataSet ds = new DataSet(); string strsql = "select * from channel where lastBuildDate = '" + lastBuildDate + "' ORDER BY 1 DESC LIMIT 1"; ds = db.ExecuteDataSet(CommandType.Text, strsql); db.Close(); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { DBChat.channelid = channelid; str.Append(dr[1].ToString() + Environment.NewLine); str.Append(dr[2].ToString() + Environment.NewLine); str.Append(dr[3].ToString() + Environment.NewLine); str.Append(dr[4].ToString() + Environment.NewLine); str.Append(dr[5].ToString() + Environment.NewLine); str.Append(dr[6].ToString() + Environment.NewLine); //str.Append(dr[7].ToString() + Environment.NewLine); str.Append(Environment.NewLine); break; } } DataTable dtDetail = DBChat.GetChatDetailBySearch(); if (dtDetail.Rows.Count > 0) { foreach (DataRow dr in dtDetail.Rows) { str.Append(dr[6].ToString() + Environment.NewLine); str.Append(dr[2].ToString() + Environment.NewLine); str.Append(dr[3].ToString() + Environment.NewLine); str.Append(Environment.NewLine); str.Append(dr[4].ToString() + Environment.NewLine); str.Append(Environment.NewLine); // str.Append(Environment.NewLine); } } return(str.ToString()); }
private void BtnDeleteby_Click(object sender, EventArgs e) { int Sharecodeid = Convert.ToInt32(cmbShareCode.SelectedValue); bool chk = ChkChat2.Checked; if (txtPass.Text == "PassAndy2015") { try { var confirmResult = MessageBox.Show("Are you sure to delete posts from database ??", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { if ((chkEnableDate.CheckState == CheckState.Unchecked) && (Sharecodeid == 0)) { var confirmResultd = MessageBox.Show("This will delete posts on given criteria from database", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResultd == DialogResult.Yes) { if (DBChat.DeleteChatDetails(chk) == true) { MessageBox.Show("All post form database has been removed", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } if ((chkEnableDate.CheckState == CheckState.Checked) && (Sharecodeid == 0)) { var confirmResult1 = MessageBox.Show("This will delete all posts by given date range", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResult1 == DialogResult.Yes) { DBChat.stdate = dpFrom.Value.ToString("yyyy/MM/dd"); DBChat.endate = dpTo.Value.ToString("yyyy/MM/dd"); DataTable dt = DBChat.GetChannelIDbyDate(chk); foreach (DataRow dr in dt.Rows) { DBChat.channelid = Convert.ToInt32(dr[0]); DBChat.DeleteChatDetailsbyChannelID(chk); } } } if ((chkEnableDate.CheckState == CheckState.Unchecked) && (Sharecodeid > 0)) { var confirmResult1 = MessageBox.Show("Are you sure to delete posts for (" + cmbShareCode.Text + ")", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResult1 == DialogResult.Yes) { DBChat.sharecodeid = Sharecodeid; DataTable dt = DBChat.GetChannelIDbyShareCode(chk); foreach (DataRow dr in dt.Rows) { DBChat.channelid = Convert.ToInt32(dr[0]); DBChat.DeleteChatDetailsbyChannelID(chk); } } } if ((chkEnableDate.CheckState == CheckState.Checked) && (Sharecodeid > 0)) { var confirmResultr = MessageBox.Show("Are you sure to delete posts for (" + cmbShareCode.Text + ") with date range", "Confirm Delete!!", MessageBoxButtons.YesNo); if (confirmResultr == DialogResult.Yes) { DBChat.stdate = dpFrom.Value.ToString("yyyy/MM/dd"); DBChat.endate = dpTo.Value.ToString("yyyy/MM/dd"); DataTable dt = DBChat.GetChannelIDbyDateAndShareCode(chk); foreach (DataRow dr in dt.Rows) { DBChat.channelid = Convert.ToInt32(dr[0]); DBChat.DeleteChatDetailsbyChannelID(chk); } } } MessageBox.Show("Post has been deleted successfully .............", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please provide password to delete Record", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }