protected void saveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (saveButton.Text == "Save")
                {
                    LC_ConstructionType aLC_ConstructionType = new LC_ConstructionType();
                    aLC_ConstructionType.ConstructionType = constructionTypeTextBox.Text;
                    aLC_ConstructionType.CreateUser       = ((SessionUser)Session["SessionUser"]).UserId;
                    aLC_ConstructionType.CreateDate       = DateTime.Now;
                    aLC_ConstructionType.OCode            = ((SessionUser)Session["SessionUser"]).OCode;

                    int result = aConstructionTypeBLL.SaveData(aLC_ConstructionType);

                    if (result == 1)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "SuccessAlert('Save Successfully!!')", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "notsuccessalert('Not Save!!')", true);
                    }
                }
                else if (saveButton.Text == "Update")
                {
                    LC_ConstructionType aLC_ConstructionType = new LC_ConstructionType();
                    aLC_ConstructionType.ConstructionType = constructionTypeTextBox.Text;
                    aLC_ConstructionType.EditUser         = ((SessionUser)Session["SessionUser"]).UserId;
                    aLC_ConstructionType.EditDate         = DateTime.Now;
                    aLC_ConstructionType.OCode            = ((SessionUser)Session["SessionUser"]).OCode;

                    int idForUpdate = Convert.ToInt32(constructionTypeHiddenField.Value);

                    int result = aConstructionTypeBLL.UpdateData(aLC_ConstructionType, idForUpdate);

                    if (result == 1)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "SuccessAlert('Update Successfully!!')", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "notsuccessalert('Not Update!!')", true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            constructionTypeTextBox.Text = "";
            LoadAllConstructionType();
            saveButton.Text = "Save";
        }
 internal int SaveData(LC_ConstructionType aLC_ConstructionType)
 {
     try
     {
         _Context.LC_ConstructionType.AddObject(aLC_ConstructionType);
         _Context.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        internal LC_ConstructionType GetSingleData(int entryId)
        {
            try
            {
                LC_ConstructionType aLC_ConstructionType = new LC_ConstructionType();

                aLC_ConstructionType = (from IName in _Context.LC_ConstructionType
                                        where IName.Id == entryId
                                        select IName).SingleOrDefault();
                return(aLC_ConstructionType);
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected void imgButtonEidt_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton imgbtn = (ImageButton)sender;
            GridViewRow row    = (GridViewRow)imgbtn.NamingContainer;

            Label lblID = (Label)constructionTypeInfo.Rows[row.RowIndex].FindControl("lblID");

            int entryId = Convert.ToInt32(lblID.Text);

            LC_ConstructionType aLC_ConstructionType = new LC_ConstructionType();

            aLC_ConstructionType = aConstructionTypeBLL.GetSingleData(entryId);

            constructionTypeHiddenField.Value = aLC_ConstructionType.Id.ToString();
            constructionTypeTextBox.Text      = aLC_ConstructionType.ConstructionType;

            saveButton.Text = "Update";
        }
        internal int UpdateData(LC_ConstructionType aLC_ConstructionType, int idForUpdate)
        {
            try
            {
                LC_ConstructionType LC_ConstructionType = _Context.LC_ConstructionType.First(x => x.Id == idForUpdate);



                LC_ConstructionType.ConstructionType = aLC_ConstructionType.ConstructionType;
                LC_ConstructionType.EditUser         = aLC_ConstructionType.EditUser;
                LC_ConstructionType.EditDate         = aLC_ConstructionType.EditDate;
                LC_ConstructionType.OCode            = aLC_ConstructionType.OCode;

                _Context.SaveChanges();
                return(1);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
 internal int UpdateData(LC_ConstructionType aLC_ConstructionType, int idForUpdate)
 {
     return(aConstructionTypeDAL.UpdateData(aLC_ConstructionType, idForUpdate));
 }
Esempio n. 7
0
 internal int SaveData(LC_ConstructionType aLC_ConstructionType)
 {
     return(aConstructionTypeDAL.SaveData(aLC_ConstructionType));
 }