private void btnGetData_Click(object sender, EventArgs e) { if (cboId.Text == "") { MessageBox.Show("select a value first and then click get data"); return; } string id = cboId.Text; DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResults = from inter in db.Interviews where inter.Id == cboId.Text select new { inter }; if (queryResults.Any()) { dtpTransDate.Text = queryResults.FirstOrDefault().inter.TransDate.ToString(); cboCompany.Text = queryResults.FirstOrDefault().inter.CompanyName; // txtName.Text = db.petitioners.Where(p => p.id == id).FirstOrDefault().name; //works fine } else { MessageBox.Show("no data found", "alert", MessageBoxButtons.OK, MessageBoxIcon.Information); } // poopulate data grid view var queryResultsDetail = from detail in db.InterviewDetails where detail.InterviewId == cboId.Text select detail; if (queryResultsDetail.Any()) { dataGridViewQuestion.DataSource = queryResultsDetail; } }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtName.Text == "") { MessageBox.Show("enter name first"); txtName.Focus(); return; } DataClassesJobDataContext db = new DataClassesJobDataContext(); Job job = new Job(); job.name = txtName.Text; job.jobTypeId = Convert.ToInt32(cboJobType.SelectedValue); db.Jobs.InsertOnSubmit(job); db.SubmitChanges(); MessageBox.Show("record saved"); } catch (Exception ex) { MessageBox.Show("error " + ex.Message); throw; } }
private void deleteInterview() { try { using (var context = new DataClassesJobDataContext()) { var savedInt = context.Interviews.Where(r => r.Id == cboId.Text); if (savedInt.Any()) { var interview = savedInt.First(); interview.Id = cboId.Text; interview.TransDate = dtpTransDate.Value; interview.CompanyId = Convert.ToInt32(cboCompany.SelectedValue); interview.CompanyName = cboCompany.Text; context.Interviews.DeleteOnSubmit(interview); context.SubmitChanges(); MessageBox.Show("Record successfully deleted !"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
private void FrmInterview_Load(object sender, EventArgs e) { //get company DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResultsCompany = from c in db.CompanyProfiles select c; if (queryResultsCompany.Any()) { cboCompany.DataSource = queryResultsCompany; cboCompany.DisplayMember = "name"; cboCompany.ValueMember = "id"; } // get questions var queryResultsQuestion = from q in db.Questions select q; if (queryResultsQuestion.Any()) { cboQuestion.DataSource = queryResultsQuestion; cboQuestion.DisplayMember = "question1"; cboQuestion.ValueMember = "Id"; } groupBoxContent.Enabled = false; }
private void contextMenuStripJob_MouseClick(object sender, MouseEventArgs e) { // delete the record string id = dataGridViewJob.Rows[0].Cells["Id"].Value.ToString(); int idInt = Convert.ToInt32(id); try { using (var context = new DataClassesJobDataContext()) { var savedJob = context.ApplyJobDetails.Where(r => r.Id == idInt); if (savedJob.Any()) { var cou = savedJob.First(); cou.Id = idInt; cou.ApplyJobId = cboId.Text; cou.CompanyId = Convert.ToInt32(cboCompany.SelectedValue); cou.JobId = Convert.ToInt32(cboJob.SelectedValue); context.ApplyJobDetails.DeleteOnSubmit(cou); context.SubmitChanges(); MessageBox.Show("Record successfully deleted !"); dataGridViewJob.Refresh(); } } } catch (Exception ex) { MessageBox.Show("Error " + ex.Message); } }
private void btnGetData_Click(object sender, EventArgs e) { try { if (cboId.Text == "") { MessageBox.Show("select a value first and then click get data"); return; } int id = Convert.ToInt16(cboId.Text); DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResults = from comp in db.CompanyProfiles where comp.id == Convert.ToInt16(cboId.Text) select new { comp }; if (queryResults.Any()) { txtName.Text = queryResults.FirstOrDefault().comp.name; txtDescription.Text = queryResults.FirstOrDefault().comp.description; // txtName.Text = db.petitioners.Where(p => p.id == id).FirstOrDefault().name; //works fine } else { MessageBox.Show("no data found", "alert", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { try { DataClassesJobDataContext db = new DataClassesJobDataContext(); #region check if company name exists var queryResults = from c in db.CompanyProfiles where c.name == txtName.Text select c; if (queryResults.Any()) { MessageBox.Show(txtName.Text + " already exists"); return; } #endregion CompanyProfile company = new CompanyProfile(); company.description = txtDescription.Text; company.name = txtName.Text; db.CompanyProfiles.InsertOnSubmit(company); db.SubmitChanges(); MessageBox.Show("record saved!"); clearFields(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void FrmApplyJob_Load(object sender, EventArgs e) { DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResultsJob = from j in db.Jobs select j; if (queryResultsJob.Any()) { cboJob.DataSource = queryResultsJob; cboJob.ValueMember = "id"; cboJob.DisplayMember = "name"; } var queryResultsComp = from c in db.CompanyProfiles select c; if (queryResultsComp.Any()) { cboCompany.DataSource = queryResultsComp; cboCompany.DisplayMember = "name"; cboCompany.ValueMember = "id"; } //todo get data in list box of todays date var queryResultsListBox = from trans in db.ApplyJobs where trans.Transdate == Convert.ToDateTime(dtpDate.Text) select trans.Id; if (queryResultsListBox.Any()) { listBoxJob.DataSource = queryResultsListBox; } }
private void btnGetData_Click(object sender, EventArgs e) { try { if (cboId.Text == "") { MessageBox.Show("select a value first and then click get data"); return; } string id = cboId.Text; DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResults = from question in db.Questions where question.Id == Convert.ToInt32(cboId.Text) select new { question }; if (queryResults.Any()) { txtName.Text = queryResults.FirstOrDefault().question.question1; //cboJobType.ValueMember = queryResults.FirstOrDefault().job.jobTypeId.ToString(); // txtName.Text = db.petitioners.Where(p => p.id == id).FirstOrDefault().name; //works fine } else { MessageBox.Show("no data found", "alert", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private void btnGetData_Click(object sender, EventArgs e) { try { if (cboId.Text == "") { MessageBox.Show("select a value first and then click get data"); return; } string id = cboId.Text; DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResults = from job in db.ApplyJobs where job.Id == cboId.Text select new { job }; if (queryResults.Any()) { string jobName, companyName; int jobId, compId; dtpDate.Text = queryResults.FirstOrDefault().job.Transdate.ToString(); // jobId =Convert.ToInt32( db.ApplyJobDetails.Where(j => j.ApplyJobId == (queryResults.FirstOrDefault().job.Id)).FirstOrDefault().ApplyJobId); // look at how query is matched . we get company id by matching from parent and childs table // compId = Convert.ToInt32(db.ApplyJobDetails.Where(j => j.CompanyId == queryResults.FirstOrDefault().job.ApplyJobDetails.FirstOrDefault().CompanyId)); //compId = Convert.ToInt32(db.ApplyJobDetails.Where(j => j.ApplyJobId == queryResults.FirstOrDefault().job.ApplyJobDetails.FirstOrDefault().ApplyJobId).FirstOrDefault().CompanyId); //jobName = db.Jobs.Where(j => j.id == jobId).FirstOrDefault().name; //companyName = db.CompanyProfiles.Where(c => c.id == compId).FirstOrDefault().name; //cboCompany.Text = companyName; //cboJob.Text = jobName; // populate datagrid var queryResultsGrid = from j in db.ApplyJobDetails where j.ApplyJobId == cboId.Text select j; if (queryResultsGrid.Any()) { dataGridViewJob.DataSource = queryResultsGrid; } //cboJobType.ValueMember = queryResults.FirstOrDefault().job.jobTypeId.ToString(); // txtName.Text = db.petitioners.Where(p => p.id == id).FirstOrDefault().name; //works fine } else { MessageBox.Show("no data found", "alert", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private void getDataInCboJobType() { DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResults = from j in db.JobTypes select j; if (queryResults.Any()) { cboJobType.DataSource = queryResults; cboJobType.DisplayMember = "name"; cboJobType.ValueMember = "id"; } }
private void btnSave_Click(object sender, EventArgs e) { try { DataClassesJobDataContext db = new DataClassesJobDataContext(); JobType jobType = new JobType(); jobType.name = txtName.Text; db.JobTypes.InsertOnSubmit(jobType); db.SubmitChanges(); MessageBox.Show("record saved!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { using (var context = new DataClassesJobDataContext()) { var job = context.JobTypes.Where(r => r.Id == Convert.ToInt16(cboId.Text)); if (job.Any()) { var ans = job.First(); ans.name = txtName.Text; context.SubmitChanges(); MessageBox.Show("Record successfully Updated !"); } } }
private void btnUpdate_Click(object sender, EventArgs e) { using (var context = new DataClassesJobDataContext()) { var ques = context.Questions.Where(r => r.Id == Convert.ToInt16(cboId.Text)); if (ques.Any()) { var com = ques.First(); com.question1 = txtName.Text; context.SubmitChanges(); MessageBox.Show("Record successfully Updated !"); ClearFields(); } } }
private void btnDelete_Click(object sender, EventArgs e) { using (var context = new DataClassesJobDataContext()) { var savedQuestion = context.Questions.Where(r => r.Id == Convert.ToInt16(cboId.Text)); if (savedQuestion.Any()) { var ques = savedQuestion.First(); ques.question1 = txtName.Text; context.Questions.DeleteOnSubmit(ques); context.SubmitChanges(); MessageBox.Show("Record successfully deleted !"); } } }
private void btnUpdate_Click(object sender, EventArgs e) { using (var context = new DataClassesJobDataContext()) { var job = context.Jobs.Where(r => r.id == Convert.ToInt16(cboId.Text)); if (job.Any()) { var jb = job.First(); jb.name = txtName.Text; jb.jobTypeId = (int)cboJobType.SelectedValue; context.SubmitChanges(); MessageBox.Show("Record successfully Updated !"); clearFields(); } } }
private Boolean IsUserValid(string username, string password) { DataClassesJobDataContext db = new DataClassesJobDataContext(); var queryResults = from u in db.Users where u.UserName == username && u.Password == password select u; if (queryResults.Any()) { setValurForId = queryResults.FirstOrDefault().id; return(true); } else { return(false); } }
private void btnSave_Click(object sender, EventArgs e) { try { DataClassesJobDataContext db = new DataClassesJobDataContext(); Question question = new Question(); question.question1 = txtName.Text; db.Questions.InsertOnSubmit(question); db.SubmitChanges(); MessageBox.Show("saved successfully"); } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
private void btnUpdate_Click(object sender, EventArgs e) { using (var context = new DataClassesJobDataContext()) { var comp = context.CompanyProfiles.Where(r => r.id == Convert.ToInt16(cboId.Text)); if (comp.Any()) { var com = comp.First(); com.name = txtName.Text; com.description = txtDescription.Text; context.SubmitChanges(); MessageBox.Show("Record successfully Updated !"); clearFields(); } } }
private void btnDelete_Click(object sender, EventArgs e) { using (var context = new DataClassesJobDataContext()) { var savedCompany = context.CompanyProfiles.Where(r => r.id == Convert.ToInt16(cboId.Text)); if (savedCompany.Any()) { var comp = savedCompany.First(); comp.name = txtName.Text; comp.description = txtDescription.Text; context.CompanyProfiles.DeleteOnSubmit(comp); context.SubmitChanges(); MessageBox.Show("Record successfully deleted !"); } } }
private void btnDelete_Click(object sender, EventArgs e) { using (var context = new DataClassesJobDataContext()) { var savedJOb = context.ApplyJobs.Where(r => r.Id == cboId.Text); if (savedJOb.Any()) { var job = savedJOb.First(); job.Id = (string)cboId.SelectedValue; job.Transdate = Convert.ToDateTime(dtpDate.Text); context.ApplyJobs.DeleteOnSubmit(job); context.SubmitChanges(); MessageBox.Show("Record successfully deleted !"); } else { MessageBox.Show("no id selected"); } } }
private void btnAdd_Click(object sender, EventArgs e) { try { DataClassesJobDataContext db = new DataClassesJobDataContext(); ApplyJobDetail jobDetail = new ApplyJobDetail(); //check if item already exists in sales detail table with same transId //var item = from i in db.ApplyJobDetails // where i.ItemId.Equals(DropDownListItemName.SelectedItem.Value) && i.SaleId == LabelSaleId.Text // select i; //if (item.Any()) //{ // LabelMessage.ForeColor = System.Drawing.Color.Red; // LabelMessage.Text = DropDownListItemName.SelectedItem.Text + " already exists. please update or delete it to make a new entry"; // // txtNetTotal.Text = "0"; // return; //} // generate Sale Id manually by random // var random = Guid.NewGuid().ToString().Replace("-", null); if (cboId.Text == "*" || cboId.Text == "") { MessageBox.Show("please click the new button"); return; } /* * vendor.ItemTypeId = Convert.ToInt32(DropDownList1.SelectedItem.Value); * vendor.itemTypeName = DropDownList1.SelectedItem.Text; * * insert data into master table (sale) before inserting data into child table(saleDetail) */ #region insert data into master tabel // insert data into master table var queryResults = from s in db.ApplyJobs where s.Id == cboId.Text select s; if (queryResults.Any()) { MessageBox.Show("id already exists"); return; } else { //insert new transId ApplyJob job = new ApplyJob(); job.Id = cboId.Text; job.Transdate = Convert.ToDateTime(dtpDate.Text); db.ApplyJobs.InsertOnSubmit(job); db.SubmitChanges(); } #endregion jobDetail.JobId = (int)cboJob.SelectedValue; jobDetail.CompanyId = (int)cboCompany.SelectedValue; jobDetail.ApplyJobId = cboId.Text; db.ApplyJobDetails.InsertOnSubmit(jobDetail); db.SubmitChanges(); MessageBox.Show("item added in detail"); // bind saleDetail data to grid view var applyDetail = from s in db.ApplyJobDetails where s.ApplyJobId == cboId.Text select s; // var list = new List<object> { queryResults }; dataGridViewJob.DataSource = applyDetail; // show notification for delete notifyIconRightClick.ShowBalloonTip(3, "Tip", "right click on datagrid to get context menu", ToolTipIcon.Info); } catch (Exception ex) { MessageBox.Show(ex.Message); } }