Example #1
0
 internal int InsertProject(Inv_Store_Unit InvStoreUnit)
 {
     try
     {
         _context.Inv_Store_Unit.AddObject(InvStoreUnit);
         _context.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
 internal int UpdateProject(Inv_Store_Unit InvStoreUnit, int projectId)
 {
     try
     {
         Inv_Store_Unit InvPro = _context.Inv_Store_Unit.First(x => x.Store_Unit_Id == projectId);
         InvPro.Store_Unit_Name = InvStoreUnit.Store_Unit_Name;
         InvPro.Unit_Track_No   = InvStoreUnit.Unit_Track_No;
         InvPro.Location        = InvStoreUnit.Location;
         InvPro.Description     = InvStoreUnit.Description;
         _context.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
 internal int InsertProject(Inv_Store_Unit InvStoreUnit)
 {
     return(aStoreUnitDAL.InsertProject(InvStoreUnit));
 }
Example #4
0
 internal int UpdateProject(Inv_Store_Unit InvStoreUnit, int projectId)
 {
     return(aStoreUnitDAL.UpdateProject(InvStoreUnit, projectId));
 }
Example #5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Inv_Store_Unit InvStoreUnit = new Inv_Store_Unit();

                InvStoreUnit.Store_Unit_Name    = txtName.Text;
                InvStoreUnit.Unit_Track_No      = txtUnitTrackNo.Text;
                InvStoreUnit.Store_Unit_Type_Id = Convert.ToInt32(ddlstoreunit.SelectedValue);
                if (txtDescription.Text == "")
                {
                    InvStoreUnit.Description = "n/a";
                }
                else
                {
                    InvStoreUnit.Description = txtDescription.Text;
                }
                InvStoreUnit.Location = txtLocation.Text;

                if (btnSubmit.Text == "Submit")
                {
                    int Projectcount = (from Prj in _context.Inv_Store_Unit
                                        where Prj.Store_Unit_Name == InvStoreUnit.Store_Unit_Name
                                        select Prj.Store_Unit_Id).Count();

                    InvStoreUnit.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                    InvStoreUnit.OCode    = ((SessionUser)Session["SessionUser"]).OCode;

                    if (Projectcount == 0)
                    {
                        int result = aStoreUnitBLL.InsertProject(InvStoreUnit);
                        if (result == 1)
                        {
                            // lblMessage.Text = "Data Saved Successfully";
                            // lblMessage.ForeColor = System.Drawing.Color.Green;
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true);
                            GetAllStoreUnit();
                            txtName.Text = "";
                            txtName.Focus();
                            txtUnitTrackNo.Text = "";
                            ddlstoreunit.ClearSelection();
                            txtLocation.Text    = "";
                            txtDescription.Text = "";
                        }
                        else
                        {
                            //lblMessage.Text = "Data Saving Failure";
                            //lblMessage.ForeColor = System.Drawing.Color.Red;
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saving Failure')", true);
                        }
                    }
                    else
                    {
                        // lblMessage.Text = "Data Already Exist";
                        // lblMessage.ForeColor = System.Drawing.Color.Red;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Already Exist')", true);
                        txtName.Text = "";
                        txtName.Focus();
                        txtUnitTrackNo.Text = "";
                        ddlstoreunit.ClearSelection();
                        txtLocation.Text    = "";
                        txtDescription.Text = "";
                        btnSubmit.Text      = "Submit";
                    }
                }
                else
                {
                    int projectId = Convert.ToInt32(hdfID.Value);

                    int result = aStoreUnitBLL.UpdateProject(InvStoreUnit, projectId);
                    if (result == 1)
                    {
                        //lblMessage.Text = "Data Updated Sucessfully";
                        // lblMessage.ForeColor = System.Drawing.Color.Green;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Sucessfully')", true);
                        GetAllStoreUnit();
                        txtName.Text = "";
                        txtName.Focus();
                        txtUnitTrackNo.Text = "";
                        ddlstoreunit.ClearSelection();
                        txtLocation.Text    = "";
                        txtDescription.Text = "";
                        btnSubmit.Text      = "Submit";
                    }
                    else
                    {
                        // lblMessage.Text = "Data Updating failure";
                        // lblMessage.ForeColor = System.Drawing.Color.Red;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updating failure')", true);
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }