Пример #1
0
        /// <summary>
        /// To save details to database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string message      = string.Empty;
            string AlertMessage = string.Empty;

            objFloorType    = new FloorTypeBO();
            objFloorTypeBLL = new FloorTypeBLL();

            //Assignement
            objFloorType.FloorTypeName = txtFloorType.Text.Trim();

            if (ViewState["FloorTypeID"] != null)
            {
                objFloorType.FloorTypeID = Convert.ToInt32(ViewState["FloorTypeID"].ToString());
            }

            objFloorType.IsDeleted = "False";

            //if (Session["USER_ID"] != null)
            objFloorType.CreatedBy = Convert.ToInt32(Session["USER_ID"].ToString());

            if (objFloorType.FloorTypeID < 1)
            {
                //If FloorTypeID does Not exists then SaveFloorType
                objFloorType.FloorTypeID = -1;//For New FloorType
                message = objFloorTypeBLL.AddFloorType(objFloorType);

                AlertMessage = "alert('" + message + "');";

                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data saved successfully";
                    ClearDetails();
                    BindGrid(true, false);
                }
            }
            else
            {
                //If FloorTypeID exists then UpdateFloorType
                message = objFloorTypeBLL.UpdateFloorType(objFloorType); //For Updating FloorType

                AlertMessage = "alert('" + message + "');";

                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data updated successfully";
                    ClearDetails();
                    BindGrid(true, false);
                }
            }
            //ClearDetails();

            AlertMessage = "alert('" + message + "');";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
            SetUpdateMode(false);
        }