internal static bool AddDetailsInt(InterviewModel interview) { var rowsAffected = 0; using (OleDbCommand dbCommand = new OleDbCommand()) { // Set the command object properties dbCommand.Connection = new OleDbConnection(connectionString); dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = "Insert Into [InterviewStatus$](SlNo, Company, Recruiter, EventDate,EventTime, Status, Result, InterviewMonth, InterviewYear, Active )" + " Values (@slnos, @company, @recruiter, @eventDate, @eventTime, @status, @result, @interviewMonth, @interviewYear, @active)"; // Update the input parameters to the parameter collection dbCommand.Parameters.AddWithValue("@slnos", interview.SlNo); dbCommand.Parameters.AddWithValue("@company", interview.Company); dbCommand.Parameters.AddWithValue("@recruiter", interview.Recruiter); dbCommand.Parameters.AddWithValue("@eventDate", interview.EventDate); dbCommand.Parameters.AddWithValue("@eventTime", interview.EventTime); dbCommand.Parameters.AddWithValue("@status", interview.Status); dbCommand.Parameters.AddWithValue("@result", interview.Result); dbCommand.Parameters.AddWithValue("@interviewMonth", interview.InterviewMonth); dbCommand.Parameters.AddWithValue("@interviewYear", interview.InterviewYear); dbCommand.Parameters.AddWithValue("@active", interview.Active); // Open the connection, execute the query and close the connection dbCommand.Connection.Open(); rowsAffected = dbCommand.ExecuteNonQuery(); dbCommand.Connection.Close(); } return(rowsAffected > 0); }
internal static bool UpdateInterview(InterviewModel interview) { using (OleDbCommand dbCommand = new OleDbCommand()) { // Set the command object properties dbCommand.Connection = new OleDbConnection(connectionString); dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = "Update [InterviewStatus$] " + " Set [EventDate1] = @eventdate, [EventTime1] = @eventtime, [Status1] = @status, [Result] = @result " + "Where ([SlNo] = @slnos)"; // Add the input parameters to the parameter collection //dbCommand.Parameters.AddWithValue("@company", interview.Company); dbCommand.Parameters.AddWithValue("@eventdate", interview.EventDate1); dbCommand.Parameters.AddWithValue("@eventtime", interview.EventTime1); dbCommand.Parameters.AddWithValue("@status", interview.Status1); dbCommand.Parameters.AddWithValue("@result", interview.Result); //dbCommand.Parameters.AddWithValue("@interviewmonth", interview.InterviewMonth); //dbCommand.Parameters.AddWithValue("@interviewyear", interview.InterviewYear); dbCommand.Parameters.AddWithValue("@slnos", interview.SlNo); // Open the connection, execute the query and close the connection dbCommand.Connection.Open(); var rowsAffected = dbCommand.ExecuteNonQuery(); dbCommand.Connection.Close(); return(rowsAffected > 0); } }
private void btnIntUpdate_Click(object sender, EventArgs e) { //company = txtCompany.Text.Trim(); date = dtpDate.Value.ToShortDateString(); time = dtpTime.Value.ToShortTimeString(); status = cmbStatusInt.SelectedItem.ToString(); if (cmbResult.SelectedText.ToString() != String.Empty) { result = cmbResult.SelectedText.ToString(); } else { result = "Awaiting"; } try { InterviewModel interview = new InterviewModel() { //Company = company, EventDate1 = date, EventTime1 = time, Status1 = status, //Active = active, Result = result, InterviewMonth = DataAccess.ConvertIntToMonth(dtpDate.Value.Month), InterviewYear = dtpDate.Value.Year, SlNo = int.Parse(txtSlnos.Text) }; bool flag = DataAccess.UpdateInterview(interview); if (flag) { DataTable data = DataAccess.GetAllRecordsInt(true); //this.LoadDataGridView(data); MessageBox.Show("Updated Successfully"); DataTable intdata = DataAccess.GetLastIdInt(); { slnos = int.Parse(intdata.Rows[0]["Expr1000"].ToString()) + 1; } txtSlnos.Text = slnos.ToString(); txtCompany.Text = ""; txtRecruiter.Text = ""; cmbStatusInt.Text = "Select"; cmbResult.Text = "Awaiting"; dtpDate.Text = DateTime.Now.ToShortDateString(); dtpTime.Text = DateTime.Now.ToShortDateString(); btnIntAdd.Enabled = true; btnIntUpdate.Enabled = false; btnIntDelete.Enabled = false; LoadGridView(); } } catch (Exception ex) { MessageBox.Show(ex.Message); txtCompany.Text = ""; } }
private void btnIntAdd_Click(object sender, EventArgs e) { slnos = int.Parse(txtSlnos.Text); if (txtCompany.Text == string.Empty || txtRecruiter.Text == string.Empty || cmbStatusInt.Text == "Select") { MessageBox.Show("Check the Company Name" + Environment.NewLine + "Check the Recruiter Name" + Environment.NewLine + "Check the Status" + Environment.NewLine + "Check the Result"); } else { company = txtCompany.Text.Trim(); recruiter = txtRecruiter.Text.Trim(); date = dtpDate.Value.ToShortDateString(); time = dtpTime.Value.ToShortTimeString(); status = cmbStatusInt.SelectedItem.ToString(); if (cmbResult.SelectedText.ToString() == "") { result = "Awaiting"; } } InterviewModel interview = new InterviewModel() { SlNo = slnos, Company = company, Recruiter = recruiter, EventDate = date, EventTime = time, Status = status, Result = result, Active = active, InterviewMonth = DataAccess.ConvertIntToMonth(dtpDate.Value.Month), InterviewYear = dtpDate.Value.Year }; var success = DataAccess.AddDetailsInt(interview); if (success) { MessageBox.Show("Added successfully"); txtCompany.Text = ""; txtRecruiter.Text = ""; cmbStatusInt.Text = "Select"; cmbResult.Text = "Awaiting"; btnIntDelete.Enabled = true; DataTable data = DataAccess.GetLastIdInt(); { slnos = int.Parse(data.Rows[0]["Expr1000"].ToString()) + 1; } txtSlnos.Text = slnos.ToString(); txtCompany.Focus(); LoadGridView(); } else { MessageBox.Show("Check the error"); } }