private void expSaveBtn_Click(object sender, EventArgs e) { string query = ""; if (stIDTEXT.Text.Trim() == "") { MessageBox.Show("Please Enter Employee ID"); stIDTEXT.Focus(); return; } if (CompanyNameText.Text.Trim() == "") { MessageBox.Show("Please Enter Company Name"); CompanyNameText.Focus(); return; } if (Workedas.Text.Trim() == "") { MessageBox.Show("Please Enter Designation!"); Workedas.Focus(); return; } if (expdurnumbering.Text.Trim() == "") { MessageBox.Show("Please Enter Experience Year!"); expdurnumbering.Focus(); return; } if (joiiningText.Text.Trim() == "") { MessageBox.Show("Please Enter Your Joining Date"); joiiningText.Focus(); return; } if (ResignedDate.Text.Trim() == "") { MessageBox.Show("Please Enter Resigned Date"); ResignedDate.Focus(); return; } query = "SELECT COUNT(*) AS Count FROM Experience_Info WHERE StaffID = " + stIDTEXT.Text + ""; if (stfID == 0) { if (DbAccess.NumberOfRecords(query) > 0) { MessageBox.Show("This username already exists! Please try another ID!"); stIDTEXT.Focus(); return; } } else { if (DbAccess.NumberOfRecords(query) > 1) { MessageBox.Show("This username already exists! Please try another ID!"); stIDTEXT.Focus(); return; } } try { if (stfID == 0) { query = "INSERT INTO Experience_Info(StaffID,CompanyName,WorkedAs,ExpDur,JoiningDate,ResignedDate) VALUES(" + Convert.ToInt32(stIDTEXT.Text) + ", '" + CompanyNameText.Text + "', '" + Workedas.Text + "', '" + Convert.ToInt32(expdurnumbering.Text) + "', '" + joiiningText.Value.ToString("yyyy/MM/dd") + "', '" + ResignedDate.Value.ToString("yyyy/MM/dd") + "' )"; } else { query = "UPDATE Experience_Info SET CompanyName = '" + CompanyNameText.Text + "', WorkedAs = '" + Workedas.Text + "', ExpDur= '" + Convert.ToInt32(expdurnumbering.Text) + "',JoiningDate = '" + joiiningText.Value.ToString("yyyy/MM/dd") + "', ResignedDate = '" + ResignedDate.Value.ToString("yyyy/MM/dd") + "' WHERE StaffID = " + stfID; } if (DbAccess.ExecuteToDB(query)) { if (stfID == 0) { MessageBox.Show("Saved Successfully!!!"); } else { MessageBox.Show("Update Successfully!!!"); } } else { MessageBox.Show("Failed To Save!!!"); } } catch (Exception ex) { MessageBox.Show("Connection Error!!!"); } finally { Reset(); } }
private void SaveTrain_Click(object sender, EventArgs e) { string query = ""; if (comStaffID.Text.Trim() == "") { MessageBox.Show("Please Enter Staff ID"); comStaffID.Focus(); return; } if (CompanyNameText.Text == "") { MessageBox.Show("Company Name"); CompanyNameText.Focus(); return; } if (TrainingNameText.Text == "") { MessageBox.Show("Please Enter Training Name"); TrainingNameText.Focus(); return; } if (TrainingInsText.Text.Trim() == "") { MessageBox.Show("Please Enter Training Institute"); TrainingInsText.Focus(); return; } if (DurationText.Text.Trim() == "") { MessageBox.Show("Please Enter Duration Time"); DurationText.Focus(); return; } if (TrainType.Text.Trim() == "") { MessageBox.Show("Please Enter Training type"); TrainType.Focus(); return; } if (traindate.Text.Trim() == "") { MessageBox.Show("Please Enter Training Date"); traindate.Focus(); return; } try { if (Hide.Text == "") { query = "INSERT INTO Training_Info(StaffID,Companyname,TrainingName,TrainingInstitute,Duration,TrainingType,TrainingDate) VALUES(" + Convert.ToInt32(comStaffID.Text) + ", '" + CompanyNameText.Text + "', '" + TrainingNameText.Text + "', '" + TrainingInsText.Text + "', '" + DurationText.Text + "', '" + TrainType.Text + "', '" + traindate.Value.ToString("yyyy/MM/dd") + "' )"; } else { query = "UPDATE Training_Info SET Companyname = '" + CompanyNameText.Text + "',TrainingInstitute = '" + TrainingInsText.Text + "', Duration= '" + DurationText.Text + "',TrainingType = '" + TrainType.Text + "',TrainingDate = '" + traindate.Value.ToString("yyyy/MM/dd") + "' WHERE ID= " + Convert.ToInt32(Hide.Text); } if (DbAccess.ExecuteToDB(query)) { if (Hide.Text == "") { MessageBox.Show("Saved Successfully!!!"); } else { MessageBox.Show("Update Successfully!!!"); } } else { MessageBox.Show("Failed To Save!!!"); } } catch (Exception ex) { MessageBox.Show("Connection Error!!!"); } finally { Reset(); } }