protected void btnCreateProj_Click(object sender, EventArgs e)
        {
            try
            {
                NBDDataSet.PROJECTRow r = dsNBD.PROJECT.NewPROJECTRow();
                //r.ID = Convert.ToInt32(this.txtID.Text);
                r.projName    = this.txtProjectName.Text;
                r.projSite    = this.txtProjectSite.Text;
                r.projBidDate = DateTime.Parse(this.txtProjBidDate.Text);
                r.clientID    = Convert.ToInt32(ddlClient.SelectedValue);
                r.designerID  = 3;
                dsNBD.PROJECT.Rows.Add(r);

                PROJECTTableAdapter daProject = new PROJECTTableAdapter();
                daProject.Update(dsNBD.PROJECT);

                ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                    "alert",
                                                    "alert('New Project Created!');window.location ='../Home.aspx';",
                                                    true);
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = "Unable to create new project." + ex.ToString();
            }
        }
Esempio n. 2
0
        public void SubmitProductionPlan(bool approved, bool Unapproved)
        {
            // Project Row #
            int n = Convert.ToInt32(ddlProjects.SelectedValue) - 1;

            try
            {
                // Project Start Date
                dsNBD.PROJECT[n].projActStart = txtProjectStart.Text;

                if (approved == true)
                {
                    dsNBD.PROJECT[n].projCurrentPhase = "P";
                }
                if (Unapproved == true)
                {
                    dsNBD.PROJECT[n].projCurrentPhase = "D";
                }

                PROJECTTableAdapter daProjects = new PROJECTTableAdapter();
                daProjects.Update(dsNBD.PROJECT);

                if (approved == true)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                        "alert",
                                                        "alert('Production Plan Has Been Approved!');window.location ='../Home.aspx';",
                                                        true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                        "alert",
                                                        "alert('Work Report Has Been Marked As Unapproved!');window.location ='../Home.aspx';",
                                                        true);
                }
            }
            catch { }
        }
        public void SubmitProductionPlan()
        {
            if (ddlProjects.SelectedValue != "-2")
            {
                //PROJECT ID
                int n = Convert.ToInt32(ddlProjects.SelectedValue) - 1;

                try
                {
                    //Project Start Date
                    dsNBD.PROJECT[n].projActStart = txtProjectStart.Text;

                    PROJECTTableAdapter daProjects = new PROJECTTableAdapter();
                    daProjects.Update(dsNBD.PROJECT);
                }
                catch { }

                //PLANTS LISTS
                List <string> PlantQ    = new List <string>();
                List <string> PlantDesc = new List <string>();
                List <string> PlantD    = new List <string>();
                List <string> PlantI    = new List <string>();

                //POTTERY LISTS
                List <string> PotteryQ    = new List <string>();
                List <string> PotteryDesc = new List <string>();
                List <string> PotteryD    = new List <string>();
                List <string> PotteryI    = new List <string>();

                //MATERIALS LISTS
                List <string> MaterialQ    = new List <string>();
                List <string> MaterialDesc = new List <string>();
                List <string> MaterialD    = new List <string>();
                List <string> MaterialI    = new List <string>();

                //PLANTS
                foreach (TextBox txt in phPlantsOgControls.Controls.OfType <TextBox>())
                {
                    if (txt.ID.Contains("PlantQ"))
                    {
                        PlantQ.Add(txt.Text);
                    }
                    if (txt.ID.Contains("PlantD"))
                    {
                        PlantD.Add(txt.Text);
                    }
                    if (txt.ID.Contains("PlantI"))
                    {
                        PlantI.Add(txt.Text);
                    }
                }
                foreach (DropDownList ddl in phPlantsOgControls.Controls.OfType <DropDownList>())
                {
                    PlantDesc.Add(ddl.SelectedValue);
                }

                for (int i = 0; i < PlantQ.Count(); i++)
                {
                    //ADDS NEW ROW TO MATERIAL_REQ
                    NBDDataSet.MATERIAL_REQRow r = dsNBD.MATERIAL_REQ.NewMATERIAL_REQRow();
                    int matID = 0;
                    int invID = 0;

                    DataRow[] rowMatID = dsNBD.MATERIAL.Select("matDesc='" + PlantDesc[i] + "'");
                    foreach (DataRow row in rowMatID)
                    {
                        matID = Convert.ToInt32(row.ItemArray[0].ToString());
                    }

                    DataRow[] rowInvID = dsNBD.INVENTORY.Select("materialID=" + matID.ToString());
                    foreach (DataRow row in rowInvID)
                    {
                        invID = Convert.ToInt32(row.ItemArray[0].ToString());
                    }

                    r.projectID   = Convert.ToInt32(ddlProjects.SelectedValue);
                    r.inventoryID = invID;
                    r.mreqDeliver = Convert.ToDateTime(PlantD[i]);
                    r.mreqInstall = Convert.ToDateTime(PlantI[i]);
                    r.mreqActQty  = Convert.ToInt16(PlantQ[i]);
                    r.mreqEstQty  = Convert.ToInt16(PlantQ[i]);

                    dsNBD.MATERIAL_REQ.Rows.Add(r);
                    MATERIAL_REQTableAdapter daMaterialReq = new MATERIAL_REQTableAdapter();
                    daMaterialReq.Update(dsNBD.MATERIAL_REQ);

                    ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                        "alert",
                                                        "alert('Production Plan Submitted!');window.location ='../Home.aspx';",
                                                        true);
                }

                //POTTERY
                foreach (TextBox txt in phPotteryOgControls.Controls.OfType <TextBox>())
                {
                    if (txt.ID.Contains("PotteryQ"))
                    {
                        PotteryQ.Add(txt.Text);
                    }
                    if (txt.ID.Contains("PotteryD"))
                    {
                        PotteryD.Add(txt.Text);
                    }
                    if (txt.ID.Contains("PotteryI"))
                    {
                        PotteryI.Add(txt.Text);
                    }
                }
                foreach (DropDownList ddl in phPotteryOgControls.Controls.OfType <DropDownList>())
                {
                    PotteryDesc.Add(ddl.SelectedValue);
                }

                for (int i = 0; i < PotteryQ.Count(); i++)
                {
                    NBDDataSet.MATERIAL_REQRow r = dsNBD.MATERIAL_REQ.NewMATERIAL_REQRow();
                    int matID = 0;
                    int invID = 0;

                    DataRow[] rowMatID = dsNBD.MATERIAL.Select("matDesc='" + PotteryDesc[i] + "'");
                    foreach (DataRow row in rowMatID)
                    {
                        matID = Convert.ToInt32(row.ItemArray[0].ToString());
                    }

                    DataRow[] rowInvID = dsNBD.INVENTORY.Select("materialID=" + matID.ToString());
                    foreach (DataRow row in rowInvID)
                    {
                        invID = Convert.ToInt32(row.ItemArray[0].ToString());
                    }

                    r.projectID   = Convert.ToInt32(ddlProjects.SelectedValue);
                    r.inventoryID = invID;
                    r.mreqDeliver = Convert.ToDateTime(PotteryD[i]);
                    r.mreqInstall = Convert.ToDateTime(PotteryI[i]);
                    r.mreqActQty  = Convert.ToInt16(PotteryQ[i]);
                    r.mreqEstQty  = Convert.ToInt16(PotteryQ[i]);

                    dsNBD.MATERIAL_REQ.Rows.Add(r);
                    MATERIAL_REQTableAdapter daMaterialReq = new MATERIAL_REQTableAdapter();
                    daMaterialReq.Update(dsNBD.MATERIAL_REQ);

                    lblMessage.Text = "Production Plan Submitted";
                }

                //MATERIALS
                foreach (TextBox txt in phMaterialsOgControls.Controls.OfType <TextBox>())
                {
                    if (txt.ID.Contains("MaterialQ"))
                    {
                        MaterialQ.Add(txt.Text);
                    }
                    if (txt.ID.Contains("MaterialD"))
                    {
                        MaterialD.Add(txt.Text);
                    }
                    if (txt.ID.Contains("MaterialI"))
                    {
                        MaterialI.Add(txt.Text);
                    }
                }
                foreach (DropDownList ddl in phMaterialsOgControls.Controls.OfType <DropDownList>())
                {
                    MaterialDesc.Add(ddl.SelectedValue);
                }

                for (int i = 0; i < MaterialQ.Count(); i++)
                {
                    NBDDataSet.MATERIAL_REQRow r = dsNBD.MATERIAL_REQ.NewMATERIAL_REQRow();
                    int matID = 0;
                    int invID = 0;

                    DataRow[] rowMatID = dsNBD.MATERIAL.Select("matDesc='" + MaterialDesc[i] + "'");
                    foreach (DataRow row in rowMatID)
                    {
                        matID = Convert.ToInt32(row.ItemArray[0].ToString());
                    }

                    DataRow[] rowInvID = dsNBD.INVENTORY.Select("materialID=" + matID.ToString());
                    foreach (DataRow row in rowInvID)
                    {
                        invID = Convert.ToInt32(row.ItemArray[0].ToString());
                    }

                    r.projectID   = Convert.ToInt32(ddlProjects.SelectedValue);
                    r.inventoryID = invID;
                    r.mreqDeliver = Convert.ToDateTime(MaterialD[i]);
                    r.mreqInstall = Convert.ToDateTime(MaterialI[i]);
                    r.mreqActQty  = Convert.ToInt16(MaterialQ[i]);
                    r.mreqEstQty  = Convert.ToInt16(MaterialQ[i]);

                    dsNBD.MATERIAL_REQ.Rows.Add(r);
                    MATERIAL_REQTableAdapter daMaterialReq = new MATERIAL_REQTableAdapter();
                    daMaterialReq.Update(dsNBD.MATERIAL_REQ);

                    lblMessage.Text = "Production Plan Submitted";
                }
            }

            else
            {
                lblMessage.Text = "Please select a project before attempting to submit.";
            }
        }