Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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 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);
            }
        }
Beispiel #5
0
        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 !");
                }
            }
        }
Beispiel #6
0
        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();
                }
            }
        }
Beispiel #7
0
        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 !");
                }
            }
        }
Beispiel #8
0
 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);
     }
 }
Beispiel #9
0
        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();
                }
            }
        }
Beispiel #10
0
 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 !");
                }
            }
        }
Beispiel #13
0
        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");
                }
            }
        }
Beispiel #14
0
        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);
            }
        }