Esempio n. 1
0
        //Adds laboursummary information for design bid
        protected void btnAddLabourSummaryDesign_Click(object sender, EventArgs e)
        {
            try
            {
                //Create instance of labour summary
                LABOUR_SUMMARY ls = new LABOUR_SUMMARY();

                //Gather information needed in order to create labour summary for specefic project
                ls.projectID = Convert.ToInt32(this.ddlProjectID.SelectedValue);
                ls.lsHours = Convert.ToInt16(this.txtLabourSummaryHoursDesign.Text);
                ls.workerTypeID = this.ddlLabourSummaryDescDesign.SelectedIndex + 1;

                //Add labour summary to database
                db.LABOUR_SUMMARY.Add(ls);
                db.SaveChanges();

                //Refresh the gridview
                gvLabourSummaryDesign.DataBind();
            }
            catch
            {
                lblErrormsgLabourSummaryDesign.Text = "Something went wrong!";
            }

            //Set textboxes and drop down back to default
            txtLabourSummaryHoursDesign.Text = "";
            ddlLabourSummaryDescDesign.SelectedIndex = 0;
        }
Esempio n. 2
0
        //Deletes labour summary information for design bid
        protected void btnSubLabourSummary_Click(object sender, EventArgs e)
        {
            try
            {
                //Create instance of labour summary with ID of textbox value
                var ls = new LABOUR_SUMMARY { ID = Convert.ToInt32(txtSubLabourSummary.Text) };
                //Attach records
                db.LABOUR_SUMMARY.Attach(ls);
                //Remove record
                db.LABOUR_SUMMARY.Remove(ls);
                db.SaveChanges();
                //Refresh gridview
                gvLabourSummaryDesign.DataBind();
            }
            catch
            {
                lblErrormsgLabourSummaryDesign.Text = "Please select a valid row to delete!";
            }

            //Set textbox back to default
            txtSubLabourSummary.Text = "";
        }