コード例 #1
0
 internal int InsertStoreunit(Inv_Store_Unit_Type InvStore)
 {
     try
     {
         _context.Inv_Store_Unit_Type.AddObject(InvStore);
         _context.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
 internal int UpdateStoreunit(Inv_Store_Unit_Type InvStore, int ID)
 {
     try
     {
         Inv_Store_Unit_Type InvStoreUnit = _context.Inv_Store_Unit_Type.First(x => x.Store_UnitType_Id == ID);
         InvStoreUnit.Store_UnitType_Name = InvStore.Store_UnitType_Name;
         InvStoreUnit.Icon_Path           = InvStore.Icon_Path;
         InvStoreUnit.Description         = InvStore.Description;
         _context.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Inv_Store_Unit_Type InvStore = new Inv_Store_Unit_Type();

                InvStore.Store_UnitType_Name = txtName.Text;
                InvStore.Icon_Path           = txtIconPath.Text;
                //InvStore.Description = txtDescription.Text;

                if (txtDescription.Text == "")
                {
                    InvStore.Description = "n/a";
                }
                else
                {
                    InvStore.Description = txtDescription.Text;
                }

                if (btnSubmit.Text == "Submit")
                {
                    int storeUnitcount = (from str in _context.Inv_Store_Unit_Type
                                          where str.Store_UnitType_Name == InvStore.Store_UnitType_Name
                                          select str.Store_UnitType_Id).Count();

                    InvStore.EditDate = DateTime.Now;
                    InvStore.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                    InvStore.OCode    = ((SessionUser)Session["SessionUser"]).OCode;

                    if (storeUnitcount == 0)
                    {
                        int result = aStoreUnitTypeBLL.InsertStoreunit(InvStore);
                        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        = "";
                            txtDescription.Text = "";
                            txtIconPath.Text    = "";
                            txtName.Focus();
                        }
                        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        = "";
                        txtIconPath.Text    = "";
                        txtDescription.Text = "";
                        txtName.Focus();
                        btnSubmit.Text = "Submit";
                    }
                }
                else
                {
                    int ID = Convert.ToInt32(hdfID.Value);

                    int result = aStoreUnitTypeBLL.UpdateStoreunit(InvStore, ID);
                    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        = "";
                        txtDescription.Text = "";
                        txtIconPath.Text    = "";
                        txtName.Focus();
                        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);
            }
        }