private void bindClass() { dataclass dc = new dataclass(); SqlConnection sc = dc.con(); SqlDataAdapter da = new SqlDataAdapter(" select (CLS_DESC +' '+ SEC_DESC) as Class ,* from View_fillfeecollection order by SEC_ID ", sc); DataSet ds = new DataSet(); da.Fill(ds); DataRow row = ds.Tables[0].NewRow(); row["Class"] = "-Select-"; row["SEC_ID"] = 0; ds.Tables[0].Rows.InsertAt(row, 0); cmbClass.DataSource = ds.Tables[0]; cmbClass.DisplayMember = "Class"; cmbClass.ValueMember = "SEC_ID"; //dataclass dc = new dataclass(); //SqlConnection sc = dc.con(); //SqlDataAdapter da = new SqlDataAdapter(" select * from class-t", sc); //DataSet ds = new DataSet(); //da.Fill(ds); //DataRow row = ds.Tables[0].NewRow(); //row["CLS_DESC"] = "Select"; //row["CLS_ID"] = 0; //ds.Tables[0].Rows.InsertAt(row, 0); //cmbClass.DataSource = ds.Tables[0]; //cmbClass.DisplayMember = "CLS_DESC"; //cmbClass.ValueMember = "CLS_ID"; }
private void LoadGrid() { dataclass dc = new dataclass(); SqlConnection sc = dc.con(); SqlDataAdapter da = new SqlDataAdapter("select * from CASTE_T where CASTE_DESC like '" + txtstatename.Text + "%' ORDER BY CASTE_DESC", sc); DataSet ds = new DataSet(); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; }
private void LoadGrid() { dataclass dc = new dataclass(); SqlConnection sc = dc.con(); SqlDataAdapter da = new SqlDataAdapter("select CLS_DESC,CLS_SEQUENCE,CLS_ID from CLASS_T where CLS_DESC like '" + txtClassname.Text + "%' ORDER BY CLS_SEQUENCE", sc); DataSet ds = new DataSet(); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; }
private void txtsequence_Leave(object sender, EventArgs e) { btnUpdate.Enabled = true; dataclass dc = new dataclass(); SqlConnection sc = dc.con(); SqlDataAdapter da = new SqlDataAdapter(" select * from Class_T where CLS_SEQUENCE='" + txtsequence.Text + "' ", sc); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { MyMessageBox.ShowBox(" This Sequence is Already Exists!!!"); btnUpdate.Enabled = false; } }
private void btnPrint_Click(object sender, EventArgs e) { DateTime dt11 = Convert.ToDateTime(dateTimePicker1.Value, System.Globalization.CultureInfo.InvariantCulture); DateTime dt12 = Convert.ToDateTime(dateTimePicker2.Value, System.Globalization.CultureInfo.InvariantCulture); dataclass dc = new dataclass(); SqlConnection conn = dc.con(); SqlDataAdapter objCmd = new SqlDataAdapter("select * from View_chequebounce where CBdate between '" + dt11.ToString("MM/dd/yyyy") + "' and'" + dt12.ToString("MM/dd/yyyy") + "'", conn); DataSet dt = new DataSet(); objCmd.Fill(dt); if (dt.Tables.Count > 0) { ExportDataSetToExcel(dt); } }
private void bindExam() { dataclass dc = new dataclass(); SqlConnection sc = dc.con(); SqlDataAdapter da = new SqlDataAdapter(" select * from EXAMINATION_T", sc); DataSet ds = new DataSet(); da.Fill(ds); DataRow row = ds.Tables[0].NewRow(); row["EXAM_DESC"] = "Select"; row["EXAM_ID"] = 0; ds.Tables[0].Rows.InsertAt(row, 0); cmbExam.DataSource = ds.Tables[0]; cmbExam.DisplayMember = "EXAM_DESC"; cmbExam.ValueMember = "EXAM_ID"; }
private void btnUpdate_Click(object sender, EventArgs e) { dataclass dd = new dataclass(); SqlConnection sc = dd.con(); if (txtclassid.Text == "") { MyMessageBox.ShowBox("Please Click to Detail Row!!!"); return; } if (txtClassname.Text == "") { MyMessageBox.ShowBox("Class Should not be blank..."); } else { SqlCommand com = new SqlCommand("update_Class_T '" + txtclassid.Text + "','" + txtClassname.Text + "','" + txtsequence.Text + "'", sc); SqlDataReader dr; sc.Open(); try { dr = com.ExecuteReader(); if (dr.RecordsAffected > 0) { MyMessageBox.ShowBox("Class Updated..."); Cancil_form(); LoadGrid(); } else { MyMessageBox.ShowBox("This Class Name already exist"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sc.Close(); } } }
private void bindclass() { dataclass dc = new dataclass(); SqlConnection sc = dc.con(); SqlDataAdapter da = new SqlDataAdapter(" select SEC_ID, (CLS_DESC + SEC_DESC) as Class from CLASS_T ct,SECTION_T st where ct.CLS_ID =st.SEC_CLS_ID order by ct.CLS_ID ", sc); DataSet ds = new DataSet(); da.Fill(ds); DataRow row = ds.Tables[0].NewRow(); row["SEC_ID"] = 0; row["Class"] = "Select"; ds.Tables[0].Rows.InsertAt(row, 0); cmbclass.DataSource = ds.Tables[0]; cmbclass.DisplayMember = "Class"; cmbclass.ValueMember = "SEC_ID"; }
private void btn_create_Click(object sender, EventArgs e) { DateTime dt1 = Convert.ToDateTime(DateTime.Now, System.Globalization.CultureInfo.InvariantCulture); dataclass dd = new dataclass(); SqlConnection sc = dd.con(); string str = sc.DataSource.ToString(); if (txtClassname.Text == "") { MyMessageBox.ShowBox("Class name should not be blank"); return; } //SqlCommand com = new SqlCommand("Insert_Class_T '" + txtClassname.Text + "','" + txtsequence.Text + "','" + sms.Form1.GlobalLoginUserName.ToString() + "','" + dt1 + "','" + sc.WorkstationId + "'", sc); SqlCommand com = new SqlCommand("Insert_Class_T '" + txtClassname.Text + "','" + txtsequence.Text + "'", sc); SqlDataReader dr; sc.Open(); try { dr = com.ExecuteReader(); if (dr.RecordsAffected > 0) { MyMessageBox.ShowBox("Class Created..."); Cancil_form(); LoadGrid(); } else { MyMessageBox.ShowBox("This Class and Sequence Name already exist"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sc.Close(); } }
private void btn_delete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are You Sure Delete Test!!!", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { dataclass dc = new dataclass(); SqlConnection conn = dc.con(); if (txtclassid.Text == "") { MyMessageBox.ShowBox("Please Click to Detail Row!!!"); return; } SqlCommand objCmd = new SqlCommand("DELETE_CLASS_T " + txtclassid.Text + "", conn); SqlDataReader dr; objCmd.Connection.Open(); dr = objCmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.RecordsAffected > 0) { MyMessageBox.ShowBox(" Class Deleted Successfully!!!"); Cancil_form(); InitGrid(); } else { MyMessageBox.ShowBox(" Class Already Used!!!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (dialogResult == DialogResult.No) { //do something else } }
private void btn_create_Click(object sender, EventArgs e) { DateTime dt1 = Convert.ToDateTime(DateTime.Now, System.Globalization.CultureInfo.InvariantCulture); dataclass dd = new dataclass(); SqlConnection sc = dd.con(); string str = sc.DataSource.ToString(); if (txtstatename.Text == "") { MyMessageBox.ShowBox("Caste Should not be blank..."); } else { SqlCommand com = new SqlCommand("Insert_caste '" + txtstatename.Text + "'", sc); SqlDataReader dr; sc.Open(); try { dr = com.ExecuteReader(); if (dr.RecordsAffected > 0) { MyMessageBox.ShowBox("Caste Created..."); Cancil_form(); LoadGrid(); } else { MyMessageBox.ShowBox("This Caste Name already exist"); } } catch (Exception ex) { } finally { sc.Close(); } } }