protected void rptSkills_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            int ID = Convert.ToInt32(e.CommandArgument);
            if (e.CommandName == "DeleteSkill")
            {
                objEmployee.DelEmpSkill(Convert.ToInt32(Session["EmpID"]), ID);

                var DC  = new DataClassesDataContext();
                int cnt = (from obj in DC.tblEmpAppraisals
                           where obj.EmpID == Convert.ToInt32(Session["EmpID"])
                           select obj).Count();

                if (cnt > 0)
                {
                    tblEmpAppraisal data = (from obj in DC.tblEmpAppraisals
                                            where obj.EmpID == Convert.ToInt32(Session["EmpID"])
                                            select obj).SingleOrDefault();
                    data.Skills = data.Skills.Value - 1;
                }
                else
                {
                    tblEmpAppraisal Skill = new tblEmpAppraisal();
                    Skill.EmpID          = Convert.ToInt32(Session["EmpID"]);
                    Skill.Skills         = Convert.ToDecimal(-1.0);
                    Skill.Quality        = Convert.ToDecimal(0.0);
                    Skill.Avialibility   = Convert.ToDecimal(0.0);
                    Skill.Deadlines      = Convert.ToDecimal(0.0);
                    Skill.Communication  = Convert.ToDecimal(0.0);
                    Skill.Cooperation    = Convert.ToDecimal(0.0);
                    Skill.ClientFeedback = Convert.ToDecimal(0.0);
                    Skill.CreatedOn      = DateTime.Now;
                    DC.tblEmpAppraisals.InsertOnSubmit(Skill);
                }
                DC.SubmitChanges();
            }
            BindData();
        }
        catch (Exception ex)
        {
            int    session    = Convert.ToInt32(Session["EmpID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "Employee", session, 0, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            var       DC         = new DataClassesDataContext();
            tblModule ModuleData = DC.tblModules.Single(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text));
            tblTeam   TeamData   = DC.tblTeams.Single(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text));
            int       cnt        = DC.tblTeamModules.Count(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text));
            if (cnt > 0)
            {
                tblTeamModule TeamModuleNewData = DC.tblTeamModules.Single(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text));
                if (ddTeamLeader.SelectedValue != "")
                {
                    tblNotification NotificationCancel = new tblNotification();
                    NotificationCancel.Title       = "Team Leader Cancelling";
                    NotificationCancel.Description = "You are cancel Team Leader for" + " " + ModuleData.Title + " " + "work in" + " " + lblProName.Text;
                    NotificationCancel.CreatedOn   = DateTime.Now;
                    NotificationCancel.CreatedBy   = Convert.ToInt32(Session["EmpID"]);
                    DC.tblNotifications.InsertOnSubmit(NotificationCancel);
                    DC.SubmitChanges();
                    tblNotification NID = (from obID in DC.tblNotifications
                                           orderby obID.NotificationID descending
                                           select obID).First();
                    tblNotificationDetail DetailCancel = new tblNotificationDetail();
                    DetailCancel.NotificationID = NID.NotificationID;
                    DetailCancel.PersonID       = TeamModuleNewData.EmpID;
                    DetailCancel.IsAdmin        = false;
                    DetailCancel.IsRead         = false;
                    DetailCancel.IsNotify       = false;
                    DC.tblNotificationDetails.InsertOnSubmit(DetailCancel);
                    TeamModuleNewData.EmpID = Convert.ToInt32(ddTeamLeader.SelectedValue);
                    //Notification Cancellation
                }
                //Notification
                tblNotification Notification = new tblNotification();
                Notification.Title       = "Assign Team Leader";
                Notification.Description = "You are selected Team Leader for" + " " + ModuleData.Title + " " + "work in" + " " + lblProName.Text;
                Notification.CreatedOn   = DateTime.Now;
                Notification.CreatedBy   = Convert.ToInt32(Session["EmpID"]);
                DC.tblNotifications.InsertOnSubmit(Notification);
                DC.SubmitChanges();
                tblNotification NID2 = (from obID in DC.tblNotifications
                                        orderby obID.NotificationID descending
                                        select obID).First();
                tblNotificationDetail Detail = new tblNotificationDetail();
                Detail.NotificationID = NID2.NotificationID;
                Detail.PersonID       = TeamModuleNewData.EmpID;
                Detail.IsAdmin        = false;
                Detail.IsRead         = false;
                Detail.IsNotify       = false;
                DC.tblNotificationDetails.InsertOnSubmit(Detail);
            }
            else
            {
                if (ddTeamLeader.SelectedValue != "")
                {
                    tblTeamModule TeamModuleNewData = new tblTeamModule();
                    TeamModuleNewData.EmpID     = Convert.ToInt32(ddTeamLeader.SelectedValue);
                    TeamModuleNewData.TeamID    = TeamData.TeamID;
                    TeamModuleNewData.CreatedOn = DateTime.Now;
                    TeamModuleNewData.CreatedBy = Convert.ToInt32(Session["EmpID"]);
                    TeamModuleNewData.ModuleID  = Convert.ToInt32(ltrModuleID.Text);
                    DC.tblTeamModules.InsertOnSubmit(TeamModuleNewData);
                    DC.SubmitChanges();
                    //Notification
                    tblNotification Notification = new tblNotification();
                    Notification.Title       = "Assign Team Leader";
                    Notification.Description = "You are selected Team Leader for" + " " + ModuleData.Title + " " + "work in" + " " + lblProName.Text;
                    Notification.CreatedOn   = DateTime.Now;
                    Notification.CreatedBy   = Convert.ToInt32(Session["EmpID"]);
                    DC.tblNotifications.InsertOnSubmit(Notification);
                    DC.SubmitChanges();
                    tblNotification NID = (from obID in DC.tblNotifications
                                           orderby obID.NotificationID descending
                                           select obID).First();
                    tblNotificationDetail Detail = new tblNotificationDetail();
                    Detail.NotificationID = NID.NotificationID;
                    Detail.PersonID       = TeamModuleNewData.EmpID;
                    Detail.IsAdmin        = false;
                    Detail.IsRead         = false;
                    Detail.IsNotify       = false;
                    DC.tblNotificationDetails.InsertOnSubmit(Detail);
                }
            }
            ModuleData.Title       = txtModuleName.Text;
            ModuleData.Description = txtCkEditor.Text;
            tblProject ProjectData = DC.tblProjects.Single(ob => ob.ProjectID == ModuleData.ProjectID);
            if (txtDDate.Text != "")
            {
                if (Convert.ToDateTime(txtDDate.Text) < ProjectData.DeadlineDate && Convert.ToDateTime(txtDDate.Text) > ModuleData.AssignDate)
                {
                    if (txtDDate.Text == "")
                    {
                        if (lblDDate.Text != "Select Deadline Date")
                        {
                            ModuleData.DeadlineDate = Convert.ToDateTime(lblDDate.Text);
                        }
                    }
                    else
                    {
                        ModuleData.DeadlineDate = Convert.ToDateTime(txtDDate.Text);
                    }
                }
                else
                {
                    Session["errorDDate"] = true;
                }
            }
            if (ddPriority.SelectedValue != "")
            {
                ModuleData.Priority = Convert.ToInt32(ddPriority.SelectedValue);
            }
            if (ddRisk.SelectedValue != "")
            {
                ModuleData.Risk = Convert.ToInt32(ddRisk.SelectedValue);
            }
            if (ddState.SelectedIndex == 3)
            {
                int TaskPanding = DC.tblTasks.Count(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text) && ob.State != 4);
                if (TaskPanding > 0)
                {
                    Session["errorClose"] = true;
                }
                else
                {
                    ModuleData.State = Convert.ToInt32(ddState.SelectedValue);
                }
            }
            else
            {
                ModuleData.State = Convert.ToInt32(ddState.SelectedValue);
            }

            if ((DC.tblTeamModules.Count(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text))) > 0)
            {
                tblTeamModule MemberData      = DC.tblTeamModules.Single(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text));
                int           cntEmpAppraisal = DC.tblEmpAppraisals.Count(ob => ob.EmpID == MemberData.EmpID);

                if (MemberData.EmpID != null)
                {
                    if (cntEmpAppraisal > 0)
                    {
                        tblEmpAppraisal EmpAppraisalData = DC.tblEmpAppraisals.Single(ob => ob.EmpID == MemberData.EmpID);
                        EmpAppraisalData.Quality       = EmpAppraisalData.Quality + Convert.ToDecimal(rngQuality.Text);
                        EmpAppraisalData.Avialibility  = EmpAppraisalData.Avialibility + Convert.ToDecimal(rngAvialibility.Text);
                        EmpAppraisalData.Communication = EmpAppraisalData.Communication + Convert.ToDecimal(rngCommunication.Text);
                        EmpAppraisalData.Cooperation   = EmpAppraisalData.Cooperation + Convert.ToDecimal(rngCooperation.Text);
                    }
                    else
                    {
                        int cntAppraisal = DC.tblTeamModules.Count(ob => ob.ModuleID == Convert.ToInt32(ltrModuleID.Text));
                        //Response.Redirect(cntAppraisal.ToString());
                        if (cntAppraisal > 0)
                        {
                            tblEmpAppraisal EmpAppraisalData = new tblEmpAppraisal();
                            EmpAppraisalData.EmpID         = MemberData.EmpID;
                            EmpAppraisalData.Quality       = Convert.ToDecimal(rngQuality.Text);
                            EmpAppraisalData.Avialibility  = Convert.ToDecimal(rngAvialibility.Text);
                            EmpAppraisalData.Communication = Convert.ToDecimal(rngCommunication.Text);
                            EmpAppraisalData.Cooperation   = Convert.ToDecimal(rngCooperation.Text);
                            EmpAppraisalData.Skills        = Convert.ToDecimal(0.0);
                            EmpAppraisalData.Deadlines     = Convert.ToDecimal(0.0);
                            EmpAppraisalData.CreatedOn     = DateTime.Now;
                            EmpAppraisalData.CreatedBy     = Convert.ToInt32(Session["EmpID"]);
                            DC.tblEmpAppraisals.InsertOnSubmit(EmpAppraisalData);
                        }
                    }
                }
            }

            DC.SubmitChanges();
            Response.Redirect("ModuleDetail.aspx");
        }
        catch (Exception ex)
        {
            int    session    = Convert.ToInt32(Session["EmpID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "Employee", session, 0, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }
Ejemplo n.º 3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (CheckForInternetConnection() == true)
        {
            try
            {
                var DC = new DataClassesDataContext();
                int ProjectID;
                if (ddProduct.SelectedValue != null)
                {
                    ProjectID = Convert.ToInt32(ddProduct.SelectedValue);
                }
                else
                {
                    ProjectID = 0;
                }

                //if (txtRate.Value == "5")
                //{
                //    Point = 5;
                //}
                //else if (txtRate.Value == "4")
                //{
                //    Point = 4;
                //}
                //else if (txtRate.Value == "3")
                //{
                //    Point = 3;
                //}
                //else if (txtRate.Value == "2")
                //{
                //    Point = 2;
                //}
                //else if (txtRate.Value == "1")
                //{
                //    Point = 1;
                //}
                //else
                //{
                //    Point = 5;
                //}

                int Point = Convert.ToInt32(txtRate.Value);

                int count = DC.tblFeedbacks.Count(ob => ob.ClientID == Convert.ToInt32(Session["ClientID"]) && ob.ProjectID == Convert.ToInt32(ddProduct.SelectedValue));
                if (count > 0)
                {
                    tblFeedback FeedbackPoint = (from ob in DC.tblFeedbacks
                                                 where ob.ClientID == Convert.ToInt32(Session["ClientID"]) && ob.ProjectID == Convert.ToInt32(ddProduct.SelectedValue)
                                                 select ob).Single();
                    FeedbackPoint.FeedBackPoint = Point;
                    DC.SubmitChanges();
                    ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('FeedBack Successfully Submitted');window.location ='Default.aspx'</script>");
                }
                else
                {
                    bool obj = objFeedBack.GiveFeedback(txtEmail.Text, ProjectID, Point, txtEnquiry.Text);
                    if (obj == true)
                    {
                        //IList<string> vc;
                        tblFeedback FeedbackID = (from ob in DC.tblFeedbacks
                                                  orderby ob.FeedbackID descending
                                                  select ob).First();
                        tblFeedback Client = (from ob in DC.tblFeedbacks
                                              where ob.EmailID == FeedbackID.EmailID
                                              select ob).Single();
                        DateTime    now = DateTime.Now;
                        MailMessage Msg = new MailMessage("*****@*****.**", FeedbackID.EmailID);
                        Msg.Subject = "feedback";
                        //Msg.Body = "<html><head></head><body><table><tr><td>Your E-Mail :</td><td>" + InquiryID.EmailID + "</td><br></tr><tr><p><td>" + "Your inquiry Successfull recieved and inquiry under process" + "</td></p></tr></table></body></html>";
                        Msg.Body       = "<!DOCTYPE html><html><head><title>Track My Work</title> <meta charset=\"utf - 8\"><meta name=\"viewport\" content=\"width = device - width, initial - scale = 1\"><meta http-equiv=\"X - UA - Compatible\" content=\"IE = edge\" /><style type=\"text / css\"> /* CLIENT-SPECIFIC STYLES */ body, table, td, a{-webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%;} /* Prevent WebKit and Windows mobile changing default text sizes */ table, td{mso-table-lspace: 0pt; mso-table-rspace: 0pt;} /* Remove spacing between tables in Outlook 2007 and up */ img{-ms-interpolation-mode: bicubic;} /* Allow smoother rendering of resized image in Internet Explorer */ /* RESET STYLES */ img{border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none;} table{border-collapse: collapse !important;} body{height: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important;} /* iOS BLUE LINKS */ a[x-apple-data-detectors] { color: inherit !important; text-decoration: none !important; font-size: inherit !important; font-family: inherit !important; font-weight: inherit !important; line-height: inherit !important; } /* MOBILE STYLES */ @media screen and (max-width: 525px) { /* ALLOWS FOR FLUID TABLES */ .wrapper { width: 100% !important; max-width: 100% !important; } /* ADJUSTS LAYOUT OF LOGO IMAGE */ .logo img { margin: 0 auto !important; } /* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */ .mobile-hide { display: none !important; } .img-max { max-width: 100% !important; width: 100% !important; height: auto !important; } /* FULL-WIDTH TABLES */ .responsive-table { width: 100% !important; } /* UTILITY CLASSES FOR ADJUSTING PADDING ON MOBILE */ .padding { padding: 10px 5% 15px 5% !important; } .padding-meta { padding: 30px 5% 0px 5% !important; text-align: center; } .no-padding { padding: 0 !important; } .section-padding { padding: 50px 15px 50px 15px !important; } /* ADJUST BUTTONS ON MOBILE */ .mobile-button-container { margin: 0 auto; width: 100% !important; } .mobile-button { padding: 15px !important; border: 0 !important; font-size: 16px !important; display: block !important; } } /* ANDROID CENTER FIX */ div[style*=\"margin: 16px 0; \"] { margin: 0 !important; }</style></head><body style=\"margin: 0 !important; padding: 0 !important; \"><!-- HIDDEN PREHEADER TEXT --><div style=\"display: none; font - size: 1px; color: #fefefe; line-height: 1px; font-family: Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;\"> Entice the open with some amazing preheader text. Use a little mystery and get those subscribers to read through...</div><!-- HEADER --><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <tr> <td align=\"center\" style=\" background:#008bff;\"> <!--[if (gte mso 9)|(IE)]> <table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"500\"> <tr> <td align=\"center\" valign=\"top\" width=\"500\"> <![endif]--> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"max-width: 500px;\" class=\"wrapper\"> <tr style=\" background:#008bff;\"> <td align=\"center\" valign=\"top\" style=\"padding: 15px 0;\" class=\"logo\"> <h1 style=\"color:white; background:#008bff; font-family:calibri; font-size:40px;\">Track My Work</h1> </td> </tr> </table> <!--[if (gte mso 9)|(IE)]> </td> </tr> </table> <![endif]--> </td> </tr> <tr> <td bgcolor=\"#ffffff\" align=\"center\" style=\"padding: 70px 15px 70px 15px;\" class=\"section-padding\"> <!--[if (gte mso 9)|(IE)]> <table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"500\"> <tr> <td align=\"center\" valign=\"top\" width=\"500\"> <![endif]--> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"max-width: 500px;\" class=\"responsive-table\"> <tr> <td> <!-- HERO IMAGE --> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> <!-- COPY --> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td align=\"center\" style=\"font-size: 25px; font-family: Helvetica, Arial, sans-serif; color: #333333; padding-top: 30px;\" class=\"padding\">Your Email id is</td> </tr> <tr> <td align=\"center\" style=\"padding: 20px 0 0 0; font-size: 16px; line-height: 25px; font-family: Helvetica, Arial, sans-serif; color: #666666;\" class=\"padding\">" + FeedbackID.EmailID + "</td> </tr> <tr> <td align=\"center\" style=\"font-size: 25px; font-family: Helvetica, Arial, sans-serif; color: #333333; padding-top: 30px;\" class=\"padding\">Your Feedback Successfully Submitted.. Thank You For Your Valuable Feedback..</td> </tr> <tr> <td align=\"center\" style=\"padding: 20px 0 0 0; font-size: 16px; line-height: 25px; font-family: Helvetica, Arial, sans-serif; color: #666666;\" class=\"padding\"></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <!--[if (gte mso 9)|(IE)]> </td> </tr> </table> <![endif]--> </td> </tr> <tr> <td align=\"center\" style=\"padding: 20px 0px; background:#424242; color:white;\"> <!--[if (gte mso 9)|(IE)]> <table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"500\"> <tr> <td align=\"center\" valign=\"top\" width=\"500\"> <![endif]--> <!-- UNSUBSCRIBE COPY --> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" style=\"max-width: 500px;\" class=\"responsive-table\"> <tr> <td align=\"center\" style=\"font-size: 12px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color:white;\"> <b>Track My Work</b> by:- Renown Infosys <span style=\"font-family: Arial, sans-serif; font-size: 12px; color:white;\">&nbsp;&nbsp;</span> </td> </tr> </table> <!--[if (gte mso 9)|(IE)]> </td> </tr> </table> <![endif]--> </td> </tr></table></body></html>";
                        Msg.IsBodyHtml = true;

                        SmtpClient smtp = new SmtpClient();
                        smtp.Host = "smtp.gmail.com";
                        smtp.Port = 587;
                        smtp.UseDefaultCredentials = false;
                        smtp.EnableSsl             = true;
                        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;

                        NetworkCredential MyCredentials = new NetworkCredential("*****@*****.**", "TMW2016open");
                        smtp.Credentials = MyCredentials;
                        smtp.Send(Msg);
                        ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('FeedBack Successfully Submitted');window.location ='Default.aspx'</script>");
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('Oops! Something goes wrong...');window.location ='FeedBack.aspx'</script>");
                    }
                }

                //ManagerAppraisal
                tblEmployee Manager = (from ob in DC.tblEmployees
                                       join ob2 in DC.tblProjects
                                       on ob.EmpID equals ob2.ManagerID
                                       where ob2.ProjectID == Convert.ToInt32(ddProduct.SelectedValue)
                                       select ob).Single();
                int cnt = (from ob in DC.tblEmpAppraisals
                           where ob.EmpID == Manager.EmpID
                           select ob).Count();
                if (cnt > 0)
                {
                    tblEmpAppraisal Appraisal = (from ob in DC.tblEmpAppraisals
                                                 where ob.EmpID == Manager.EmpID
                                                 select ob).Single();
                    Appraisal.ClientFeedback += Convert.ToInt32(Point);
                }
                else
                {
                    tblEmpAppraisal Appraisal = new tblEmpAppraisal();
                    Appraisal.EmpID          = Manager.EmpID;
                    Appraisal.Skills         = Convert.ToDecimal(0.0);
                    Appraisal.Quality        = Convert.ToDecimal(0.0);
                    Appraisal.Avialibility   = Convert.ToDecimal(0.0);
                    Appraisal.Deadlines      = Convert.ToDecimal(0.0);
                    Appraisal.Communication  = Convert.ToDecimal(0.0);
                    Appraisal.Cooperation    = Convert.ToDecimal(0.0);
                    Appraisal.ClientFeedback = Convert.ToDecimal(Point);
                    Appraisal.CreatedOn      = DateTime.Now;
                    DC.tblEmpAppraisals.InsertOnSubmit(Appraisal);
                    DC.SubmitChanges();
                }

                //TeamLeader
                IQueryable <tblEmployee> TeamMember = (from ob in DC.tblEmployees
                                                       join ob2 in DC.tblTeamModules
                                                       on ob.EmpID equals ob2.EmpID
                                                       join ob3 in DC.tblModules
                                                       on ob2.ModuleID equals ob3.ModuleID
                                                       where ob3.ProjectID == Convert.ToInt32(ddProduct.SelectedValue)
                                                       select ob);

                foreach (tblEmployee data in TeamMember)
                {
                    int cntEmp = (from ob in DC.tblEmpAppraisals
                                  where ob.EmpID == data.EmpID
                                  select ob).Count();
                    if (cntEmp > 0)
                    {
                        tblEmpAppraisal Appraisal = (from ob in DC.tblEmpAppraisals
                                                     where ob.EmpID == data.EmpID
                                                     select ob).Single();
                        Appraisal.ClientFeedback += Convert.ToInt32(Point);
                    }
                    else
                    {
                        tblEmpAppraisal Appraisal = new tblEmpAppraisal();
                        Appraisal.EmpID          = data.EmpID;
                        Appraisal.Skills         = Convert.ToDecimal(0.0);
                        Appraisal.Quality        = Convert.ToDecimal(0.0);
                        Appraisal.Avialibility   = Convert.ToDecimal(0.0);
                        Appraisal.Deadlines      = Convert.ToDecimal(0.0);
                        Appraisal.Communication  = Convert.ToDecimal(0.0);
                        Appraisal.Cooperation    = Convert.ToDecimal(0.0);
                        Appraisal.ClientFeedback = Convert.ToDecimal(Point);
                        Appraisal.CreatedOn      = DateTime.Now;
                        DC.tblEmpAppraisals.InsertOnSubmit(Appraisal);
                        DC.SubmitChanges();
                    }
                }

                //Employee
                IQueryable <tblEmployee> Employee = (from ob in DC.tblEmployees
                                                     join ob2 in DC.tblTeamMembers
                                                     on ob.EmpID equals ob2.EmpID
                                                     join ob3 in DC.tblTasks
                                                     on ob2.TaskID equals ob3.TaskID
                                                     join ob4 in DC.tblModules
                                                     on ob3.ModuleID equals ob4.ModuleID
                                                     where ob4.ProjectID == Convert.ToInt32(ddProduct.SelectedValue)
                                                     select ob);

                foreach (tblEmployee data in Employee)
                {
                    int cntEmp = (from ob in DC.tblEmpAppraisals
                                  where ob.EmpID == data.EmpID
                                  select ob).Count();
                    if (cntEmp > 0)
                    {
                        tblEmpAppraisal Appraisal = (from ob in DC.tblEmpAppraisals
                                                     where ob.EmpID == data.EmpID
                                                     select ob).Single();
                        Appraisal.ClientFeedback += Convert.ToInt32(Point);
                    }
                    else
                    {
                        tblEmpAppraisal Appraisal = new tblEmpAppraisal();
                        Appraisal.EmpID          = data.EmpID;
                        Appraisal.Skills         = Convert.ToDecimal(0.0);
                        Appraisal.Quality        = Convert.ToDecimal(0.0);
                        Appraisal.Avialibility   = Convert.ToDecimal(0.0);
                        Appraisal.Deadlines      = Convert.ToDecimal(0.0);
                        Appraisal.Communication  = Convert.ToDecimal(0.0);
                        Appraisal.Cooperation    = Convert.ToDecimal(0.0);
                        Appraisal.ClientFeedback = Convert.ToDecimal(Point);
                        Appraisal.CreatedOn      = DateTime.Now;
                        DC.tblEmpAppraisals.InsertOnSubmit(Appraisal);
                        DC.SubmitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                int    session    = Convert.ToInt32(Session["ClientID"].ToString());
                string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
                string MACAddress = GetMacAddress();
                AddErrorLog(ref ex, PageName, "Client", session, 0, MACAddress);
                ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Please Check your Internet Connection');", true);
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        var           DC             = new DataClassesDataContext();
        tblTask       TaskData       = DC.tblTasks.Single(ob => ob.TaskID == Convert.ToInt32(ltrTaskID.Text));
        tblModule     ModuleData     = DC.tblModules.Single(ob => ob.ModuleID == TaskData.ModuleID);
        tblTeamModule TeamModuleData = DC.tblTeamModules.Single(ob => ob.ModuleID == Convert.ToInt32(TaskData.ModuleID));
        int           cntTeamMember  = DC.tblTeamMembers.Count(ob => ob.TaskID == Convert.ToInt32(ltrTaskID.Text));

        if (cntTeamMember > 0)
        {
            tblTeamMember NewTeamMember = DC.tblTeamMembers.Single(ob => ob.TaskID == Convert.ToInt32(ltrTaskID.Text));
            if (ddEmployee.SelectedValue != "")
            {
                NewTeamMember.EmpID = Convert.ToInt32(ddEmployee.SelectedValue);
                tblNotification NotificationCancel = new tblNotification();
                NotificationCancel.Title       = "Team Leader Cancelling";
                NotificationCancel.Description = "You are cancel Employee for" + " " + TaskData.Title + " " + "work in" + " " + lblProName.Text;
                NotificationCancel.CreatedOn   = DateTime.Now;
                NotificationCancel.CreatedBy   = Convert.ToInt32(Session["EmpID"]);
                DC.tblNotifications.InsertOnSubmit(NotificationCancel);

                tblNotificationDetail DetailCancel = new tblNotificationDetail();
                DetailCancel.NotificationID = DetailCancel.NotificationID;
                DetailCancel.PersonID       = TeamModuleData.EmpID;
                DetailCancel.IsAdmin        = false;
                DetailCancel.IsRead         = false;
                DetailCancel.IsNotify       = false;
                DC.tblNotificationDetails.InsertOnSubmit(DetailCancel);
            }
            tblNotification Notification = new tblNotification();
            Notification.Title       = "Assign Team Leader";
            Notification.Description = "You are selected Employee for" + " " + TaskData.Title + " " + "work in" + " " + lblProName.Text;
            Notification.CreatedOn   = DateTime.Now;
            Notification.CreatedBy   = Convert.ToInt32(Session["EmpID"]);
            DC.tblNotifications.InsertOnSubmit(Notification);

            tblNotificationDetail Detail = new tblNotificationDetail();
            Detail.NotificationID = Notification.NotificationID;
            Detail.PersonID       = TeamModuleData.EmpID;
            Detail.IsAdmin        = false;
            Detail.IsRead         = false;
            Detail.IsNotify       = false;
            DC.tblNotificationDetails.InsertOnSubmit(Detail);
        }
        else
        {
            tblTeamMember NewTeamMember = new tblTeamMember();
            if (ddEmployee.SelectedValue != "")
            {
                NewTeamMember.EmpID = Convert.ToInt32(ddEmployee.SelectedValue);
            }
            NewTeamMember.TaskID    = Convert.ToInt32(ltrTaskID.Text);
            NewTeamMember.TeamID    = Convert.ToInt32(TeamModuleData.TeamID);
            NewTeamMember.CreatedOn = DateTime.Now;
            NewTeamMember.CreatedBy = Convert.ToInt32(Session["EmpID"]);
            DC.tblTeamMembers.InsertOnSubmit(NewTeamMember);
            tblNotification Notification = new tblNotification();
            Notification.Title       = "Assign Team Leader";
            Notification.Description = "You are selected Employee for" + " " + TaskData.Title + " " + "work in" + " " + lblProName.Text;
            Notification.CreatedOn   = DateTime.Now;
            Notification.CreatedBy   = Convert.ToInt32(Session["EmpID"]);
            DC.tblNotifications.InsertOnSubmit(Notification);

            tblNotificationDetail Detail = new tblNotificationDetail();
            Detail.NotificationID = Notification.NotificationID;
            Detail.PersonID       = TeamModuleData.EmpID;
            Detail.IsAdmin        = false;
            Detail.IsRead         = false;
            Detail.IsNotify       = false;
            DC.tblNotificationDetails.InsertOnSubmit(Detail);
        }
        TaskData.Title       = txtTaskName.Text;
        TaskData.Description = txtCkEditor.Text;
        if (txtDDate.Text == "")
        {
            TaskData.DeadlineDate = Convert.ToDateTime(lblDDate.Text);
        }
        else
        {
            TaskData.DeadlineDate = Convert.ToDateTime(txtDDate.Text);
        }
        if (ddPriority.SelectedValue != "")
        {
            TaskData.Priority = Convert.ToInt32(ddPriority.SelectedValue);
        }
        if (ddRisk.SelectedValue != "")
        {
            TaskData.Risk = Convert.ToInt32(ddRisk.SelectedValue);
        }
        TaskData.State = Convert.ToInt32(ddState.SelectedValue);
        tblTeamMember MemberData      = DC.tblTeamMembers.Single(ob => ob.TaskID == Convert.ToInt32(ltrTaskID.Text));
        int           cntEmpAppraisal = DC.tblEmpAppraisals.Count(ob => ob.EmpID == MemberData.EmpID);

        if (cntEmpAppraisal > 0)
        {
            tblEmpAppraisal EmpAppraisalData = DC.tblEmpAppraisals.Single(ob => ob.EmpID == MemberData.EmpID);
            EmpAppraisalData.Quality       = EmpAppraisalData.Quality + Convert.ToDecimal(rngQuality.Text);
            EmpAppraisalData.Avialibility  = EmpAppraisalData.Avialibility + Convert.ToDecimal(rngAvialibility.Text);
            EmpAppraisalData.Communication = EmpAppraisalData.Communication + Convert.ToDecimal(rngCommunication.Text);
            EmpAppraisalData.Cooperation   = EmpAppraisalData.Cooperation + Convert.ToDecimal(rngCooperation.Text);
        }
        else
        {
            tblEmpAppraisal EmpAppraisalData = new tblEmpAppraisal();
            EmpAppraisalData.EmpID         = MemberData.EmpID;
            EmpAppraisalData.Quality       = Convert.ToDecimal(rngQuality.Text);
            EmpAppraisalData.Avialibility  = Convert.ToDecimal(rngAvialibility.Text);
            EmpAppraisalData.Communication = Convert.ToDecimal(rngCommunication.Text);
            EmpAppraisalData.Cooperation   = Convert.ToDecimal(rngCooperation.Text);
            EmpAppraisalData.CreatedOn     = DateTime.Now;
            EmpAppraisalData.CreatedBy     = Convert.ToInt32(Session["EmpID"]);
            DC.tblEmpAppraisals.InsertOnSubmit(EmpAppraisalData);
        }
        DC.SubmitChanges();
        Response.Redirect("TaskDetail.aspx");
    }
    protected void txtAddSkill_TextChanged(object sender, EventArgs e)
    {
        try
        {
            var DC = new DataClassesDataContext();

            tblSkill SkillID = (from ob in DC.tblSkills
                                where ob.SkillName == txtAddSkill.Text
                                select ob).Single();
            int Skill = (from ob in DC.tblEmpXSkills
                         join obj in DC.tblSkills
                         on ob.SkillID equals obj.SkillID
                         where ob.EmpID == Convert.ToInt32(Session["EmpID"]) && ob.SkillID == SkillID.SkillID
                         select ob).Count();
            if (Skill > 0)
            {
                erroSkill.Text    = "Skill already exist!!";
                erroSkill.Visible = true;
            }
            else
            {
                erroSkill.Visible = false;
                objEmployee.AddEmpSkill(Convert.ToInt32(Session["EmpID"]), txtAddSkill.Text);
                txtAddSkill.Text      = "";
                panelAddSkill.Visible = false;


                BindData();

                //Employee Appraisal
                int cnt = (from obj in DC.tblEmpAppraisals
                           where obj.EmpID == Convert.ToInt32(Session["EmpID"])
                           select obj).Count();
                if (cnt > 0)
                {
                    tblEmpAppraisal data = (from obj in DC.tblEmpAppraisals
                                            where obj.EmpID == Convert.ToInt32(Session["EmpID"])
                                            select obj).SingleOrDefault();
                    data.Skills = data.Skills.Value + 1;
                    DC.SubmitChanges();
                }
                else
                {
                    tblEmployee EmpData = (from obj in DC.tblEmployees
                                           where obj.EmpID == Convert.ToInt32(Session["EmpID"])
                                           select obj).First();
                    tblEmpAppraisal EmpAppraisal = new tblEmpAppraisal();
                    EmpAppraisal.EmpID          = EmpData.EmpID;
                    EmpAppraisal.Skills         = Convert.ToDecimal(1.0);
                    EmpAppraisal.Quality        = Convert.ToDecimal(0.0);
                    EmpAppraisal.Avialibility   = Convert.ToDecimal(0.0);
                    EmpAppraisal.Deadlines      = Convert.ToDecimal(0.0);
                    EmpAppraisal.Communication  = Convert.ToDecimal(0.0);
                    EmpAppraisal.Cooperation    = Convert.ToDecimal(0.0);
                    EmpAppraisal.ClientFeedback = Convert.ToDecimal(0.0);
                    EmpAppraisal.CreatedBy      = Convert.ToInt32(Session["EmpID"]);
                    EmpAppraisal.CreatedOn      = DateTime.Now;
                    DC.tblEmpAppraisals.InsertOnSubmit(EmpAppraisal);
                }

                DC.SubmitChanges();
            }
        }
        catch (Exception ex)
        {
            int    session    = Convert.ToInt32(Session["EmpID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "Employee", session, 0, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }