Esempio n. 1
0
    protected void btnPunishmentAdd_Click(object sender, EventArgs e)
    {
        if (this.grdEmployee.SelectedIndex == -1)
        {
            this.lblStatusMessage.Text = "**कर्मचारी खोज्नुहोस्";
            this.programmaticModalPopup.Show();
            return;
        }
        if (this.txtPunishment.Text == "")
        {
            this.lblStatusMessage.Text = "**सजाय बारे भर्नुहोस्";
            this.programmaticModalPopup.Show();
        }
        if (this.txtpunishmentDate.Text == "")
        {
            this.lblStatusMessage.Text = "**सजायको मिति भर्नुहोस्";
            this.programmaticModalPopup.Show();
        }
        if (this.txtPunishmentRemarks.Text == "")
        {
            this.lblStatusMessage.Text = "**सजायको कैफियत भर्नुहोस्";
            this.programmaticModalPopup.Show();
        }
        string punishment_date = this.txtpunishmentDate.Text;
        double empidSelected   = double.Parse(Session["SelectedEmp"].ToString());

        //List<ATTAwardPunishment> LSTAwards = BLLAwardPunishment.GetAwards(empidSelected);
        //if (LSTAwards.Count > 0)
        //{
        //    foreach (ATTAwardPunishment itm in LSTAwards)
        //    {
        //        if (itm.EmpID == empidSelected && itm.AwardDate == this.txtpunishmentDate.Text)
        //        {
        //            this.lblStatusMessage.Text = "**कर्मचारीको लागी विभुषण दर्ता सोहि मितिमा भैसकेको छ.";
        //            this.programmaticModalPopup.Show();
        //            return;
        //        }
        //    }
        //}
        //if (this.grdpunishment.Rows.Count > 0)
        //{
        //    foreach (GridViewRow row in this.grdpunishment.Rows)
        //    {
        //        if (this.txtpunishmentDate.Text == row.Cells[3].Text && empidSelected.ToString() == row.Cells[0].Text && this.txtPunishment.Text==row.Cells[2].Text)
        //        {
        //            this.lblStatusMessage.Text = "**कर्मचारीको लागी सोहि मितिमा सजाय दर्ता भैसकेको छ.\n**सजाय मिति सच्याउनुहोस्.";
        //            this.programmaticModalPopup.Show();
        //            return;
        //        }
        //    }
        //}

        if (grdpunishment.SelectedIndex < 0)
        {
            if (this.grdEmployee.SelectedIndex == -1)
            {
                this.lblStatusMessage.Text = "कर्मचारी छान्नुहोस्";
                this.programmaticModalPopup.Show();
                return;
            }
            int    empid      = int.Parse(Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[0].Text).ToString());
            string empname    = Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[5].Text).ToString();
            string punishment = this.txtPunishment.Text;
            //string punishment_date = this.txtpunishmentDate.Text;
            string punishment_rem           = this.txtPunishmentRemarks.Text;
            List <ATTAwardPunishment> LSTAP = (List <ATTAwardPunishment>)Session["PrevPunishments"];
            if (LSTAP.Count == 0)
            {
                LSTAP = new List <ATTAwardPunishment>();
            }
            ATTAwardPunishment objAP = new ATTAwardPunishment();
            objAP.EmpID             = empid;
            objAP.EmpName           = empname;
            objAP.Punishment        = punishment;
            objAP.PunishmentDate    = punishment_date;
            objAP.PunishmentRemarks = punishment_rem;
            objAP.EntryBy           = Session["User"].ToString();
            objAP.Action            = "A";
            LSTAP.Add(objAP);
            Session["PrevPunishments"]    = LSTAP;
            this.grdpunishment.DataSource = LSTAP;
            this.grdpunishment.DataBind();
        }
        if (this.grdpunishment.SelectedIndex > -1)
        {
            bool valid = true;
            int  i     = 0;
            foreach (GridViewRow grow in grdpunishment.Rows)
            {
                if (i != grdpunishment.SelectedIndex)
                {
                    if (grow.Cells[3].Text.Trim() == punishment_date)
                    {
                        valid = false;
                        break;
                    }
                }
                i++;
            }
            if (valid)
            {
                int empid = int.Parse(Server.HtmlDecode(grdpunishment.Rows[grdpunishment.SelectedIndex].Cells[0].Text).ToString());
                //string empname = Server.HtmlDecode(grdAward.Rows[grdAward.SelectedIndex].Cells[5].Text).ToString();
                int    seqno                    = int.Parse(Server.HtmlDecode(grdpunishment.Rows[grdpunishment.SelectedIndex].Cells[1].Text).ToString());
                string punishment               = this.txtPunishment.Text;
                string punishment_rem           = this.txtPunishmentRemarks.Text;
                List <ATTAwardPunishment> LSTAP = (List <ATTAwardPunishment>)Session["PrevPunishments"];
                LSTAP[grdpunishment.SelectedIndex].EmpID      = empid;
                LSTAP[grdpunishment.SelectedIndex].SequenceNo = seqno;
                //LSTAP[grdAward.SelectedIndex].EmpName = empname;
                LSTAP[grdpunishment.SelectedIndex].Punishment        = punishment;
                LSTAP[grdpunishment.SelectedIndex].PunishmentDate    = punishment_date;
                LSTAP[grdpunishment.SelectedIndex].PunishmentRemarks = punishment_rem;
                LSTAP[grdpunishment.SelectedIndex].EntryBy           = Session["User"].ToString();
                string action = grdpunishment.Rows[grdpunishment.SelectedIndex].Cells[6].Text;
                LSTAP[grdpunishment.SelectedIndex].Action = "E";
                Session["Punishment"]         = LSTAP;
                this.grdpunishment.DataSource = LSTAP;
                this.grdpunishment.DataBind();
            }
            else
            {
                this.lblStatusMessage.Text = "**कर्मचारीको लागी त्यही मितिमा सजाय दर्ता भैसकेको छ .";
                this.programmaticModalPopup.Show();
                return;
            }
        }
        ClearControls("Add");
    }
    protected void btnAwardAdd_Click(object sender, EventArgs e)
    {
        string msg   = "";
        int    count = 0;

        if (this.grdEmployee.SelectedIndex == -1)
        {
            msg += "**कर्मचारी छान्नुहोस्</br>";
            count++;
        }

        if (this.txtAwardDesc.Text == "")
        {
            msg += "**विभुषणको बारे बर्नुहोस्</br>";
            count++;
        }
        if (this.txtAwardDate.Text == "")
        {
            msg += "**मिति बर्नुहोस्</br>";
            count++;
        }
        if (this.txtAwardRemarks.Text == "")
        {
            msg += "**विभुषणको कैफिएत बर्नुहोस्</br>";
            count++;
        }
        if (count > 0)
        {
            this.lblStatusMessage.Text = msg;
            this.programmaticModalPopup.Show();
            return;
        }
        double empidSelected            = double.Parse(Session["SelectedEmp"].ToString());
        List <ATTAwardPunishment> LSTAP = (List <ATTAwardPunishment>)Session["PrevAwards"];

        if (LSTAP == null)
        {
            LSTAP = new List <ATTAwardPunishment>();
        }
        string award_date = this.txtAwardDate.Text;

        if (this.grdAward.SelectedIndex < 0)
        {
            if (this.grdEmployee.SelectedIndex == -1)
            {
                this.lblStatusMessage.Text = "कर्मचारी छान्नुहोस्";
                this.programmaticModalPopup.Show();
                return;
            }

            bool exists = LSTAP.Exists(
                delegate(ATTAwardPunishment obj)
            {
                return(award_date == obj.AwardDate);
            }
                );

            if (exists)
            {
                this.lblStatusMessage.Text = "**विभुषण र मिति जाँच्नुहोस् ";
                this.programmaticModalPopup.Show();
                return;
            }
            else
            {
                double             empid     = double.Parse(Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[0].Text).ToString());
                string             empname   = Server.HtmlDecode(grdEmployee.Rows[grdEmployee.SelectedIndex].Cells[5].Text).ToString();
                string             award     = this.txtAwardDesc.Text;
                string             award_rem = this.txtAwardRemarks.Text;
                ATTAwardPunishment objAP     = new ATTAwardPunishment();
                objAP.EmpID     = empid;
                objAP.EmpName   = empname;
                objAP.Award     = award;
                objAP.AwardDate = award_date;
                objAP.Remarks   = award_rem;
                objAP.EntryBy   = Session["User"].ToString();
                objAP.Action    = "A";
                LSTAP.Add(objAP);
                this.grdAward.DataSource = LSTAP;
                this.grdAward.DataBind();
            }
        }
        if (this.grdAward.SelectedIndex > -1)
        {
            bool valid = true;
            int  i     = 0;
            foreach (GridViewRow grow in grdAward.Rows)
            {
                if (i != grdAward.SelectedIndex)
                {
                    if (grow.Cells[4].Text.Trim() == award_date)
                    {
                        valid = false;
                        break;
                    }
                }
                i++;
            }

            if (valid)
            {
                int seqno = int.Parse(Server.HtmlDecode(grdAward.Rows[grdAward.SelectedIndex].Cells[1].Text).ToString());

                string award     = this.txtAwardDesc.Text;
                string award_rem = this.txtAwardRemarks.Text;
                LSTAP[grdAward.SelectedIndex].SequenceNo = seqno;
                LSTAP[grdAward.SelectedIndex].Award      = award;
                LSTAP[grdAward.SelectedIndex].AwardDate  = award_date;
                LSTAP[grdAward.SelectedIndex].Remarks    = award_rem;
                LSTAP[grdAward.SelectedIndex].EntryBy    = Session["User"].ToString();

                string action = grdAward.Rows[grdAward.SelectedIndex].Cells[6].Text;
                if (action == "A")
                {
                    LSTAP[grdAward.SelectedIndex].Action = "A";
                }
                if (action == "" || action == "&nbsp;")
                {
                    LSTAP[grdAward.SelectedIndex].Action = "E";
                }

                Session["PrevAwards"]    = LSTAP;
                this.grdAward.DataSource = LSTAP;
                this.grdAward.DataBind();
            }
            else
            {
                this.lblStatusMessage.Text = "**कर्मचारीको लागी त्यही मितिमा विभुषण दर्ता भैसकेको छ .";
                this.programmaticModalPopup.Show();
                return;
            }
        }
        ClearControls("Add");
    }