Esempio n. 1
0
        /// <summary>
        /// Set Grid Data source
        /// </summary>
        /// <param name="addRow"></param>
        /// <param name="deleteRow"></param>e
        private void BindGrid()
        {
            RepresentationBLL objRepresentationBLL = new RepresentationBLL();

            grdRepresentation.DataSource = objRepresentationBLL.GetRepresentation();
            grdRepresentation.DataBind();
        }
Esempio n. 2
0
        /// <summary>
        /// To delete a record in database  based on representationID
        /// </summary>
        private void DeleteRepresentation(string representationID)
        {
            RepresentationBLL objRepresentationBLL = new RepresentationBLL();

            string message = string.Empty;

            try
            {
                message = objRepresentationBLL.DeleteRepresentation(Convert.ToInt32(representationID));
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data Deleted successfully";
                }

                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }

                BindGrid();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Update Database Make data as Obsoluted
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void IsObsolete_CheckedChanged(Object sender, EventArgs e)
        {
            string message = string.Empty;

            try
            {
                CheckBox    chk = (CheckBox)sender;
                GridViewRow gr  = (GridViewRow)chk.Parent.Parent;
                string      representationID = ((Literal)gr.FindControl("litUserID")).Text;

                RepresentationBLL objRepresentationBLL = new RepresentationBLL();
                message = objRepresentationBLL.ObsoleteRepresentation(Convert.ToInt32(representationID), Convert.ToString(chk.Checked));
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data updated successfully";
                }

                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }

                BindGrid();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// To fetch details from the database and assign to textbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>e
        private void GetRepresentationDetails()
        {
            RepresentationBLL objRepresentationBLL = new RepresentationBLL();
            RepresentationBO  objRepresentationBO  = new RepresentationBO();

            objRepresentationBO = objRepresentationBLL.GetRepresentationById(Convert.ToInt32(ViewState["RepresentationID"]));

            if (objRepresentationBO != null)
            {
                txtRepresentation.Text = objRepresentationBO.RepresentationName;
            }
        }
Esempio n. 5
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 = "";

            RepresentationBLL objRepresentationBLL = new RepresentationBLL();

            if (Convert.ToInt32(ViewState["RepresentationID"]) == 0)
            {
                try
                {
                    string           uID = Session["USER_ID"].ToString();
                    RepresentationBO objRepresentationBO = new RepresentationBO();
                    objRepresentationBO.RepresentationName = txtRepresentation.Text.ToString().Trim();
                    objRepresentationBO.UserID             = Convert.ToInt32(uID);
                    message = objRepresentationBLL.InsertRepresentation(objRepresentationBO);

                    if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                    {
                        message = "Data saved successfully";
                    }

                    if (message != "")
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    objRepresentationBLL = null;
                }

                ClearData();
                BindGrid();
            }
            //edit the data in the textbox exiting in the Grid
            else if (Convert.ToInt32(ViewState["RepresentationID"]) > 0)
            {
                try
                {
                    RepresentationBO objRepresentationBO = new RepresentationBO();
                    objRepresentationBO.RepresentationName = txtRepresentation.Text.ToString().Trim();
                    objRepresentationBO.RepresentationID   = Convert.ToInt32(ViewState["RepresentationID"]);
                    objRepresentationBO.UserID             = Convert.ToInt32(Session["USER_ID"]);

                    message = objRepresentationBLL.UpdateRepresentation(objRepresentationBO);

                    if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                    {
                        message = "Data updated successfully";
                    }

                    if (message != "")
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    objRepresentationBLL = null;
                }

                ClearData();
                BindGrid();
                SetUpdateMode(false);

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