示例#1
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;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        List <ATTOrganizationDesignation> OrgDesignationList = (List <ATTOrganizationDesignation>)Session["OrganizationDesignation"];
        ATTOrganizationDesignation        objOrgDesignation  = new ATTOrganizationDesignation();
        ATTPost objPost           = new ATTPost();
        int     intDesignationID  = 0;
        int     intOrganizationID = 0;
        int     intTotalSeats     = 0;
        int     intSewaID         = 0;
        int     intSamuhaID       = 0;
        int     intUpaSamuhaID    = 0;
        int     intDesgLevelID    = 0;
        string  strUser           = ((ATTUserLogin)Session["Login_User_Detail"]).UserName;

        if (this.ddlDesignation_Rqd.SelectedIndex > 0)
        {
            intDesignationID = int.Parse(this.ddlDesignation_Rqd.SelectedValue.ToString());
        }
        if (this.ddlOrganization_Rqd.SelectedIndex > 0)
        {
            intOrganizationID = int.Parse(this.ddlOrganization_Rqd.SelectedValue.ToString());
        }
        if (this.ddlSewa_Rqd.SelectedIndex > 0)
        {
            intSewaID = int.Parse(this.ddlSewa_Rqd.SelectedValue.ToString());
        }
        if (this.ddlSamuha_Rqd.SelectedIndex > 0)
        {
            intSamuhaID = int.Parse(this.ddlSamuha_Rqd.SelectedValue.ToString());
        }
        if (this.ddlUpaSamuha_Rqd.SelectedIndex > 0)
        {
            intUpaSamuhaID = int.Parse(this.ddlUpaSamuha_Rqd.SelectedValue.ToString());
        }
        if (this.ddlDesignationLevel_Rqd.SelectedIndex > 0)
        {
            intDesgLevelID = int.Parse(this.ddlDesignationLevel_Rqd.SelectedValue.ToString());
        }

        foreach (GridViewRow row in this.grdDesPost.Rows)
        {
            CheckBox chkDelete = (CheckBox)(row.Cells[8].FindControl("chkPostSelect"));
            if (!chkDelete.Checked)
            {
                intTotalSeats += 1;
            }
        }

        if (this.grdDesPost.Rows.Count == 0)
        {
            this.lblStatusMessage.Text = "Enter The Total Quantity And Click Create Post (or) Update Post.";
            this.programmaticModalPopup.Show();
            return;
        }
        try
        {
            objOrgDesignation = new ATTOrganizationDesignation(intOrganizationID, intDesignationID, intTotalSeats, intSewaID, intSamuhaID, intUpaSamuhaID, intDesgLevelID);
            ObjectValidation OV = BLLOrganizationDesignation.Validate(objOrgDesignation);
            if (!OV.IsValid)
            {
                this.lblStatusMessage.Text = OV.ErrorMessage;
                this.programmaticModalPopup.Show();
                return;
            }
            if (this.txtCreatedDate_DT.Text.Trim() != "")
            {
                objOrgDesignation.CreatedDate = this.txtCreatedDate_DT.Text.Trim(); //"2066.10.09";
            }
            objOrgDesignation.EntryBy = strUser;
            if (this.grdOrgDesignation.SelectedIndex == -1)
            {
                objOrgDesignation.Action = "A";
            }
            else
            {
                objOrgDesignation.Action = "E";
            }


            foreach (GridViewRow row in this.grdDesPost.Rows)
            {
                string strPostName    = "";
                string strOldPostName = "";

                CheckBox cb                = (CheckBox)(row.Cells[8].FindControl("chkPostSelect"));
                TextBox  txtboxPostName    = (TextBox)(row.Cells[5].FindControl("txtPostName"));
                TextBox  txtboxOldPostName = (TextBox)(row.Cells[6].FindControl("txtOldPostName"));
                strPostName     = txtboxPostName.Text.Trim();
                strOldPostName  = txtboxOldPostName.Text.Trim();
                objPost         = new ATTPost(int.Parse(row.Cells[0].Text.ToString()), int.Parse(row.Cells[1].Text.ToString()), row.Cells[8].Text.ToString(), int.Parse(row.Cells[2].Text.ToString()), strPostName, row.Cells[7].Text.ToString().Trim());
                objPost.EntryBy = strUser;
                objPost.Action  = "";
                if (row.Cells[2].Text.ToString().Trim() == "0" && !cb.Checked)
                {
                    objPost.Action = "A";
                }
                if (row.Cells[2].Text.ToString().Trim() != "0")
                {
                    if (cb.Checked)
                    {
                        objPost.Action = "D";
                    }
                    else if ((strPostName != strOldPostName) && !cb.Checked)
                    {
                        objPost.Action = "E";
                    }
                }

                if (objPost.Action != "")
                {
                    ObjectValidation OValidate = BLLPost.Validate(objPost);
                    if (!OValidate.IsValid)
                    {
                        this.lblStatusMessage.Text = OValidate.ErrorMessage;
                        this.programmaticModalPopup.Show();
                        return;
                    }
                    objOrgDesignation.LstPosts.Add(objPost);
                }
            }


            //if (this.ddlParentOrganization.SelectedIndex > 0)
            //    objOrgDesignation.ParentOrg = int.Parse(this.ddlParentOrganization.SelectedValue.ToString());
            //if (this.ddlParentDesignation.SelectedIndex > 0)
            //    objOrgDesignation.ParentDes = int.Parse(this.ddlParentDesignation.SelectedValue.ToString());
            objOrgDesignation.OrgName       = this.ddlOrganization_Rqd.SelectedItem.Text;
            objOrgDesignation.DesName       = this.ddlDesignation_Rqd.SelectedItem.Text;
            objOrgDesignation.SewaName      = this.ddlSewa_Rqd.SelectedItem.Text;
            objOrgDesignation.SamuhaName    = this.ddlSamuha_Rqd.SelectedItem.Text;
            objOrgDesignation.UpaSamuhaName = this.ddlUpaSamuha_Rqd.SelectedItem.Text;
            objOrgDesignation.DesgLevelName = this.ddlDesignationLevel_Rqd.SelectedItem.Text;

            if (BLLOrganizationDesignation.SaveOrganizationDesignation(objOrgDesignation))
            {
                if (this.grdOrgDesignation.SelectedIndex > -1)
                {
                    OrgDesignationList[this.grdOrgDesignation.SelectedIndex].OrgID      = int.Parse(this.ddlOrganization_Rqd.SelectedValue.ToString());
                    OrgDesignationList[this.grdOrgDesignation.SelectedIndex].DesID      = int.Parse(this.ddlDesignation_Rqd.SelectedValue.ToString());
                    OrgDesignationList[this.grdOrgDesignation.SelectedIndex].OrgName    = this.ddlOrganization_Rqd.SelectedItem.Text.ToString();
                    OrgDesignationList[this.grdOrgDesignation.SelectedIndex].DesName    = this.ddlDesignation_Rqd.SelectedItem.Text.ToString();
                    OrgDesignationList[this.grdOrgDesignation.SelectedIndex].TotalSeats = objOrgDesignation.TotalSeats;
                }
                else
                {
                    OrgDesignationList.Add(objOrgDesignation);
                }
                this.grdOrgDesignation.DataSource = OrgDesignationList;
                this.grdOrgDesignation.DataBind();
                this.lblStatusMessage.Text = "**Post Created Successfully";
                this.programmaticModalPopup.Show();
                ClearControls();
            }
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message;
            this.programmaticModalPopup.Show();
        }
    }