Пример #1
0
        //Add materials to the prodcution plan
        protected void btnAddMaterialProduction_Click(object sender, EventArgs e)
        {
            try
            {
                //Create instance of material_req
                MATERIAL_REQ mr = new MATERIAL_REQ();

                //Gather all information needed to create material_req
                mr.projectID = Convert.ToInt32(this.ddlProjectID.SelectedValue);
                mr.inventoryID = this.ddlMaterialDescProduction.SelectedIndex + 1;
                mr.mreqEstQty = Convert.ToInt16(this.txtQtyEstProduction.Text);
                mr.mreqDeliver = Convert.ToDateTime(this.txtMaterialDeliverProduction.Text);
                mr.mreqInstall = Convert.ToDateTime(this.txtMaterialInstallProduction.Text);

                //Save material_req to database
                db.MATERIAL_REQ.Add(mr);
                db.SaveChanges();

                //Refresh Gridview
                gvMaterialReqProduction.DataBind();
            }
            catch
            {
                lblErrormsgProductionMaterials.Text = "Something went wrong!";
            }

            //Set textboxes and dropdownlists back to default
            this.ddlMaterialDescProduction.SelectedIndex = 0;
            this.txtQtyEstProduction.Text = "";
            this.txtMaterialDeliverProduction.Text = "";
            this.txtMaterialInstallProduction.Text = "";
        }
Пример #2
0
        //Adds materials_req for design bid
        protected void btnAddMaterial_Click(object sender, EventArgs e)
        {
            try
            {
                //Add instance for material_req
                MATERIAL_REQ mr = new MATERIAL_REQ();

                //gather information to insert a new material_req for specefic project
                mr.projectID = Convert.ToInt32(this.ddlProjectID.SelectedValue);
                mr.inventoryID = this.ddlMaterialDescDesign.SelectedIndex + 1;
                mr.mreqEstQty = Convert.ToInt16(this.txtQtyEstDesign.Text);

                //add material_req to the database
                db.MATERIAL_REQ.Add(mr);
                db.SaveChanges();

                //refresh the gridview
                gvMaterialReqDesign.DataBind();
            }
            catch
            {
                lblErrormsgMaterialReqDesign.Text = "Something went wrong!";
            }

            //set the textboxes and dropdown back to defaults
            ddlMaterialDescDesign.SelectedIndex = 0;
            txtQtyEstDesign.Text = "";
        }
Пример #3
0
        protected void btnSubProductionMaterials_Click(object sender, EventArgs e)
        {
            try
            {
                //Create instance of materal_req with ID of textbox value
                var mr = new MATERIAL_REQ { ID = Convert.ToInt32(txtSubProductionMaterials) };
                //Attach records
                db.MATERIAL_REQ.Attach(mr);
                //Remove record
                db.MATERIAL_REQ.Remove(mr);
                db.SaveChanges();
                //Refresh gridview
                gvMaterialReqProduction.DataBind();
            }
            catch
            {
                lblErrormsgProductionMaterials.Text = "Please select a valid row to delete!";
            }

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