public static List <ATTPostLevel> GetPostLevel(int?PostId)
        {
            List <ATTPostLevel> LstPostLevel = new List <ATTPostLevel>();

            try
            {
                foreach (DataRow row in DLLPostLevel.GetPostLevel(PostId).Rows)
                {
                    ATTPostLevel ObjAtt = new ATTPostLevel
                                          (
                        int.Parse(row["POST_ID"].ToString()),
                        int.Parse(row["LEVEL_ID"].ToString()),
                        row["LEVEL_NAME"].ToString(),
                        ""
                                          );


                    LstPostLevel.Add(ObjAtt);
                }
                return(LstPostLevel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        List <ATTPost> PostList = (List <ATTPost>)Session["Post"];

        int PostID;

        if (lstPost.SelectedIndex == -1)
        {
            PostID = 0;
        }
        else
        {
            PostID = int.Parse(lstPost.SelectedValue.ToString());
        }
        try
        {
            ATTPost ObjAtt = new ATTPost(PostID, txtPostName_Rqd.Text.Trim());

            foreach (GridViewRow row in grdPostLevel.Rows)
            {
                if (row.Cells[3].Text.Trim() != "&nbsp;")
                {
                    ATTPostLevel attPL = new ATTPostLevel(int.Parse(row.Cells[0].Text.ToString()), int.Parse(row.Cells[1].Text.ToString()), row.Cells[2].Text.Trim(), row.Cells[3].Text.Trim());
                    ObjAtt.LstPostLevel.Add(attPL);
                }
            }

            ObjectValidation OV = BLLPost.Validate(ObjAtt);

            if (OV.IsValid == false)
            {
                lblStatusMessage.Text = OV.ErrorMessage;
                this.programmaticModalPopup.Show();
                return;
            }


            for (int i = 0; i < lstPost.Items.Count; i++)
            {
                if (lstPost.SelectedIndex != i)
                {
                    if (PostList[i].PostName.ToLower() == txtPostName_Rqd.Text.Trim().ToLower())
                    {
                        this.lblStatusMessage.Text = "Post Name Already Exists";
                        this.programmaticModalPopup.Show();
                        return;
                    }
                }
            }

            BLLPost.SavePost(ObjAtt);

            if (lstPost.SelectedIndex > -1)
            {
                PostList[lstPost.SelectedIndex].PostID   = ObjAtt.PostID;
                PostList[lstPost.SelectedIndex].PostName = ObjAtt.PostName;
                PostList[lstPost.SelectedIndex].LstPostLevel.Clear();

                foreach (GridViewRow row in grdPostLevel.Rows)
                {
                    if (row.Cells[3].Text.Trim() != "D")
                    {
                        ATTPostLevel attPL = new ATTPostLevel(int.Parse(row.Cells[0].Text.ToString()), int.Parse(row.Cells[1].Text.ToString()), row.Cells[2].Text, "");
                        PostList[lstPost.SelectedIndex].LstPostLevel.Add(attPL);
                    }
                }
            }
            else
            {
                PostList.Add(ObjAtt);
            }

            lstPost.DataSource     = PostList;
            lstPost.DataTextField  = "PostName";
            lstPost.DataValueField = "PostID";
            lstPost.DataBind();

            ClearControls();
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message;
            this.programmaticModalPopup.Show();
            return;
        }
    }