예제 #1
0
        private bool saveChanges()
        {
            bool result = true;

            try
            {
                if (Session["SessionIdForSessionDetails"] != null)
                {
                    id = Convert.ToInt32(Session["SessionIdForSessionDetails"].ToString());
                    ///////////////// update session ////////////////
                    Sessoin newSes = new Sessoin();
                    newSes.SessionID  = id;
                    newSes.SessionNum = SessionNumber.Text.ToInt();
                    newSes.Date       = tbxSessionDate.Text;
                    newSes.LGID       = (int)(db.Sessoins.Where(p => p.SessionID == id).Single().LGID);
                    SessionRepository sRep = new SessionRepository();
                    sRep.SaveSession(newSes);

                    ////////////////// update Score ///////////////////////
                    foreach (GridViewRow row in gvStudents.Rows)
                    {
                        string  stuCode = row.Cells[1].Text.ToString();
                        Nomarat nomre   = new Nomarat();

                        int ozviatid = row.Cells[0].Text.ToInt();
                        nomre.NomreID  = nr.GetNomreIDBySessionIDandOzviatID(id, ozviatid);
                        nomre.OzviatID = ozviatid;
                        int lastSession = sRep.FindLastSessionID();
                        nomre.SessionID = id;
                        //nomre.Date = tbxSessionDate.Text;
                        nomre.Nomre = (row.FindControl("Score") as TextBox).Text;
                        vNomratRepository nomreRep = new vNomratRepository();
                        nomreRep.SaveNomre(nomre);

                        ///////////////////update Present///////////////////

                        Presence presence = new Presence();
                        presence.OzviatID  = ozviatid;
                        presence.ID        = pr.GetPreseceIDBySessionIDandOzviatID(id, ozviatid);
                        presence.SessionID = sRep.FindLastSessionID();
                        //presence.Date = tbxSessionDate.Text;
                        presence.Status      = (row.FindControl("RowChBPeresece") as CheckBox).Checked;
                        presence.isMovajjah  = (row.FindControl("RowChBisMovajjah") as CheckBox).Checked;
                        presence.Description = (row.FindControl("DescriptionTbx") as TextBox).Text.ToString();
                        vPresenceRepository PRep = new vPresenceRepository();
                        PRep.SavePresenc(presence);
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('شما با آدرس اشتباه وارد شده اید ! ');window.location ='http://localhost:4911/Dashboard/Teacher/News.aspx'", true);
                }
            }
            catch (Exception e)
            {
                string s = e.Message;
                result = false;
            }
            return(result);
        }
예제 #2
0
        private bool saveChanges()
        {
            bool result           = true;
            TransactionOptions op = new TransactionOptions();

            op.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, op))
            {
                try
                {
                    if (Session["LGIDforSessionHistory"] != null)
                    {
                        id = Convert.ToInt32(Session["LGIDforSessionHistory"].ToString());
                        ///////////////// Save session ////////////////
                        Sessoin newSes = new Sessoin();
                        newSes.Date = tbxSessionDate.Text;
                        newSes.LGID = id;
                        SessionRepository sRep = new SessionRepository();
                        newSes.SessionNum = sRep.CountSessionsByLGID(id).ToInt();
                        sRep.SaveSession(newSes);

                        ////////////////// Save Score ///////////////////////
                        foreach (GridViewRow row in gvStudents.Rows)
                        {
                            string           stuCode = row.Cells[1].Text.ToString();
                            Nomarat          nomre   = new Nomarat();
                            OzviatRepository oRep    = new OzviatRepository();
                            int ozviatid             = oRep.OzviatIDByLGIDAndStudentCode(id, stuCode);
                            nomre.OzviatID = ozviatid;
                            int lastSession = sRep.FindLastSessionID();
                            nomre.SessionID = lastSession;
                            nomre.Date      = tbxSessionDate.Text;
                            nomre.Nomre     = (row.FindControl("Score") as TextBox).Text;
                            vNomratRepository nomreRep = new vNomratRepository();
                            nomreRep.SaveNomre(nomre);
                            ///////////////////Save Present///////////////////
                            Presence presence = new Presence();
                            presence.OzviatID    = ozviatid;
                            presence.SessionID   = sRep.FindLastSessionID();
                            presence.Date        = tbxSessionDate.Text;
                            presence.Status      = (row.FindControl("RowChB") as CheckBox).Checked;
                            presence.isMovajjah  = (row.FindControl("RowChB2") as CheckBox).Checked;
                            presence.Description = (row.FindControl("DescriptionTbx") as TextBox).Text.ToString();
                            vPresenceRepository PRep = new vPresenceRepository();
                            PRep.SavePresenc(presence);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('شما با آدرس اشتباه وارد شده اید ! ');window.location ='http://localhost:4911/Dashboard/Teacher/News.aspx'", true);
                    }
                    scope.Complete();
                }
                catch (Exception e)
                {
                    string s = e.Message;
                    result = false;
                }
                return(result);
            }
        }