Exemple #1
0
    public string insertALfromCal(string id, string date, string quantity)
    {
        int      numEffected   = 0;
        string   dt            = date;
        int      les_id        = Convert.ToInt16(id);
        int      Limitquantity = 0;
        DateTime start_date    = Convert.ToDateTime(dt);

        String   MyString   = date;
        DateTime MyDateTime = new DateTime();

        MyDateTime = DateTime.ParseExact(MyString, "yyyy-MM-dd", null);
        int day = (int)MyDateTime.DayOfWeek + 1;

        int          amount = Convert.ToInt32(quantity);
        ActualLesson al;

        for (int i = 0; i < amount; i++)
        {
            al           = new ActualLesson(les_id, dt, Limitquantity, day);
            numEffected += al.insertActualLesson();
            start_date   = start_date.AddDays(7);
            dt           = start_date.ToString("yyyy-MM-dd");
        }
        if (numEffected < 1)
        {
            return(null);
        }
        JavaScriptSerializer js = new JavaScriptSerializer();
        // serialize to string
        string jsonStringGetTurtering = js.Serialize(numEffected);

        return(jsonStringGetTurtering);
    }
Exemple #2
0
    protected void btnAddStu_onClick(object sender, EventArgs e)
    {
        string         stuId         = ddlSearch.SelectedValue.ToString();
        double         selectedStuId = Convert.ToDouble(stuId);
        int            lessID        = Convert.ToInt32(Session["selectedLessonNum"]);
        DateTime       lesDate       = Convert.ToDateTime(Session["selectedLessonDate"]);
        string         dateFormat    = lesDate.ToString("yyyy-MM-dd");
        ActualLesson   acl           = new ActualLesson();
        SignedToLesson stl;

        int studentsNum = Convert.ToInt32(Session["studentsNumber"]);
        int actual_quan = studentsNum + 1;

        try
        {
            stl = new SignedToLesson(lessID, dateFormat, selectedStuId);
            int numEffected3 = acl.updateSpecificActualLesson(lessID, dateFormat, actual_quan); //הגדלת כמות משתתפים ב-1
            int numEffected2 = stl.InsertSigendToLesson();                                      //הכנסת התלמיד לטבלת "רשום לתגבור"
            Server.TransferRequest(Request.Url.AbsolutePath, false);
        }
        catch (Exception ex)
        {
            Response.Write("There was an error " + ex.Message);
        }
    }
Exemple #3
0
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        Request     req         = new Request();
        GridViewRow gvRow       = (GridViewRow)(sender as Control).Parent.Parent;
        int         index       = gvRow.RowIndex;
        int         req_num     = Convert.ToInt32(gvRow.Cells[1].Text);
        int         status      = 1;
        int         numEffected = req.updateSpecificRequest(req_num, status);

        int    req_type     = 1;
        string req_typeName = gvRow.Cells[15].Text;

        if (req_typeName != "ביטול השתתפות")
        {
            req_type = 0;
        }


        ActualLesson   acl = new ActualLesson();
        SignedToLesson stl;
        double         stuId   = Convert.ToDouble(gvRow.Cells[3].Text);
        int            lesId   = Convert.ToInt32(gvRow.Cells[14].Text);
        DateTime       tmpDate = Convert.ToDateTime(gvRow.Cells[7].Text);
        string         lesDate = tmpDate.ToString("yyyy-MM-dd");


        if (req_type != 1) //אם זו בקשה להרשמה (זו לא בקשה לביטול השתתפות)
        {
            try
            {
                stl = new SignedToLesson(lesId, lesDate, stuId);
            }
            catch (Exception ex)
            {
                Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message);
                return;
            }

            int actual_quan = Convert.ToInt32(gvRow.Cells[11].Text) + 1;



            try
            {
                int numEffected3 = acl.updateSpecificActualLesson(lesId, lesDate, actual_quan); //הגדלת כמות משתתפים ב-1
                int numEffected2 = stl.InsertSigendToLesson();                                  //הכנסת התלמיד לטבלת "רשום לתגבור"
                Server.TransferRequest(Request.Url.AbsolutePath, false);
            }
            catch (Exception ex)
            {
                Response.Write("There was an error " + ex.Message);
            }
        }
    }
Exemple #4
0
    protected void cancelButton_Click(object sender, EventArgs e)
    {
        GridViewRow    gvRow     = (GridViewRow)(sender as Control).Parent.Parent;
        int            cancelled = 1;
        ActualLesson   acl       = new ActualLesson();
        SignedToLesson stl       = new SignedToLesson();
        int            lesId     = Convert.ToInt32(gvRow.Cells[1].Text);
        DateTime       tmpDate   = Convert.ToDateTime(gvRow.Cells[3].Text);
        string         lesDate   = tmpDate.ToString("yyyy-MM-dd");
        Request        stuReq    = new Request();

        string proff = gvRow.Cells[2].Text;
        string start = gvRow.Cells[4].Text;

        Session["cancelledLesId"]   = lesId;
        Session["cancelledLesDate"] = lesDate;
        string    lesDateMES  = tmpDate.ToString("dd-MM-yyyy");
        Manager   m           = (Manager)(Session["manUserSession"]);
        double    manID       = m.Man_id;
        DataTable dt          = this.GetStudents();
        string    currnetDate = DateTime.Now.ToString("yyyy-MM-dd");

        Messages mes;
        string   mesContent = "תלמיד יקר, שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " בוטל.";

        foreach (DataRow dr in dt.Rows)
        {
            double stuID = Convert.ToDouble(dr["StLes_stuId"]);

            mes = new Messages(manID, stuID, "ביטול שיעור", mesContent, false, currnetDate);
            int NumEffected = mes.InsertMessage();
        }

        DataTable teaIDtable = this.GetTeaId();
        double    teaID      = Convert.ToDouble(teaIDtable.Rows[0]["Les_Tea_Id"]);

        string   mesToTeaContent = "מתגבר יקר, שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " בוטל.";
        Messages TeaMes          = new Messages(manID, teaID, "ביטול שיעור", mesToTeaContent, false, currnetDate);
        int      numEffected1    = TeaMes.InsertMessageFromManagerToTeacher();

        try
        {
            int numEffected2 = acl.cancelSpecificActualLesson(lesId, lesDate, cancelled); //עדכון שהתגבור בוטל
            int numEffected3 = stl.deleteStudentsFromLesson(lesId, lesDate);              //מחיקת התלמידים שמשתתפים בתגבור זה בטבלת "רשום לתגבור"
            int numEffected4 = stuReq.deleteCancelldLessonRequests(lesId, lesDate);       //מחיקת כל הבקשות להרשמה לתגבור זה
            Server.TransferRequest(Request.Url.AbsolutePath, false);
        }

        catch (Exception ex)
        {
            Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message);
            return;
        }
    }
Exemple #5
0
    public ActualLesson readSpecificActualLesson(int actl_num)
    {
        DBServices   dbs    = new DBServices();
        ActualLesson DBuser = dbs.readSpecificActualLesson(actl_num, "studentDBConnectionString", "ActualLesson");

        if (DBuser == null)
        {
            return(null);
        }
        else
        {
            return(DBuser);
        }
    }
Exemple #6
0
    public void delBTNButton_Click(Object sender, EventArgs e)
    {
        SignedToLesson stl      = new SignedToLesson();
        Button         button   = (Button)sender;
        string         buttonId = button.ID;
        string         stuId    = buttonId.Substring(6);
        int            delStuId = Convert.ToInt32(stuId);
        string         lessDate = (Session["selectedLessonDate"]).ToString();
        DateTime       lesDate  = Convert.ToDateTime(lessDate);
        int            lesId    = (int)(Session["selectedLessonNum"]);
        int            numEff   = stl.deleteStudentFromLesson(delStuId, lesId, lesDate.ToString("yyyy-MM-dd"));
        ActualLesson   actl     = new ActualLesson();
        int            quan     = (int)Session["studentsNumber"] - 1;
        int            numEf    = actl.updateSpecificActualLesson(lesId, lesDate.ToString("yyyy-MM-dd"), quan);

        Server.TransferRequest(Request.Url.AbsolutePath, false);
    }
Exemple #7
0
    protected void generateDate_Click(object sender, EventArgs e)
    {
        Session["AddActualLesson"] = true;

        string       dt         = Request.Form["DatePickername"];
        int          les_id     = (int)(Session["LES_ID"]);
        int          quantity   = 0;
        DateTime     start_date = Convert.ToDateTime(dt);
        int          amount     = Convert.ToInt32(counterTB.Text);
        ActualLesson al;

        for (int i = 0; i < amount; i++)
        {
            al = new ActualLesson(les_id, dt, quantity);
            al.insertActualLesson();
            start_date = start_date.AddDays(7);
            dt         = start_date.ToString("yyyy-MM-dd");
        }
        string lessonCounter = counterTB.Text;

        Session["LessonCounterSession"] = lessonCounter;
        Response.Redirect("ShowActualLesson_admin.aspx");
    }
Exemple #8
0
    protected void generateDate_Click(object sender, EventArgs e)
    {
        Session["AddActualLesson"] = true;
        string   dt         = Request.Form["DatePickername"];
        int      les_id     = (int)(Session["LES_ID"]);
        int      quantity   = 0;
        DateTime start_date = Convert.ToDateTime(dt);
        int      amount     = Convert.ToInt32(counterTB.Text);
        int      day        = Convert.ToInt32(dayOfActLesson.Text);

        // נבדוק מי מלמד את התגבור הנבחר ואת השעות של תגבור זה
        DataTable dtTeaID = this.GetSelectedTeaId();
        double    teaID   = Convert.ToDouble(dtTeaID.Rows[0]["Les_Tea_Id"]);
        DateTime  start   = DateTime.Parse((dtTeaID.Rows[0]["Les_StartHour"]).ToString());
        DateTime  end     = DateTime.Parse((dtTeaID.Rows[0]["Les_EndHour"]).ToString());

        Session["selectedteaID"] = teaID;

        //נביא את כל התגבורים (תאריך+שעת התחלה+שעת סיום+מס תגבור) עבור מתגבר זה
        DataTable DTclassForSelectedTeaId = this.GetClassForSelectedTeaId();

        int flg = 0; //מסמן אם יש התנגשות בזמנים

        ActualLesson al;


        DataTable checkTable = new DataTable();

        checkTable.Columns.Add("flg", typeof(int));//מסמן אם ניתן להוסיף תגבור או לא- 1 ניתן 0 לא ניתן

        List <string> problemDatesList = new List <string>();
        List <string> goodDatesList    = new List <string>();

        for (int i = 0; i < amount; i++)
        {
            foreach (DataRow dr in DTclassForSelectedTeaId.Rows)
            {
                if (Convert.ToDateTime(dt) == Convert.ToDateTime(dr["ActLes_date"]))
                {
                    DateTime a = DateTime.Parse((dr["Les_StartHour"]).ToString());
                    //אם יש לו תגבור באותו יום, אבל התגבור הנבחר מתחיל ומסתיים לפני התגבורים אחרים שיש לו באותו יום- ניתן לשבץ
                    if (start < DateTime.Parse((dr["Les_StartHour"]).ToString()) && end <= DateTime.Parse((dr["Les_StartHour"]).ToString()))
                    {
                        DataRow newRow = checkTable.NewRow();
                        // Set values in the columnn:
                        newRow["flg"] = 1;
                        // Add the row to the rows collection.
                        checkTable.Rows.Add(newRow);
                    }
                    //אם יש לו תגבור באותו יום, אבל התגבור הנבחר מתחיל אחרי שהתגבורים אחרים שיש לו באותו יום כבר התחילו והסתיימו- ניתן לשבץ
                    else if (start > DateTime.Parse((dr["Les_StartHour"]).ToString()) && start >= DateTime.Parse((dr["Les_EndHour"]).ToString()))
                    {
                        DataRow newRow = checkTable.NewRow();
                        // Set values in the column
                        newRow["flg"] = 1;
                        // Add the row to the rows collection.
                        checkTable.Rows.Add(newRow);
                    }
                    else //כל מצב אחר אומר שיש תגבור למתגבר באותו התאריך וגם השעות מתנגשות
                    {
                        DataRow newRow = checkTable.NewRow();
                        // Set values in the column
                        newRow["flg"] = 0;
                        // Add the row to the rows collection.
                        checkTable.Rows.Add(newRow);
                    }
                }
            }

            if (checkTable.Rows.Count > 0)
            {
                foreach (DataRow dr in checkTable.Rows)
                {
                    if (Convert.ToInt32(dr["flg"]) != 1)
                    {
                        flg = 1;
                        break;//מספיק שלפחות אחד מהתגבורים בתאריך זה מתנגש עם שעות התגבור הנבחר
                    }
                }
                if (flg == 1)
                {
                    DateTime date = Convert.ToDateTime(dt);
                    string   d    = date.ToString("dd'/'MM'/'yyyy");
                    problemDatesList.Add(d);
                }

                else //אף אחד מהתגבורים שקיימים כבר לא מתנגשים עם התאריך הנבחר
                {
                    al = new ActualLesson(les_id, dt, quantity, day);
                    al.insertActualLesson();;
                    DateTime date2 = Convert.ToDateTime(dt);
                    string   good  = date2.ToString("dd'/'MM'/'yyyy");
                    goodDatesList.Add(good);
                }
            }

            else //אם אין שורות בטבלה המשמעות שאין למתגבר תגבורים אחרים באותו יום ולכן אין בעיית שיבוץ וניתן להוסיף את התגבור
            {
                al = new ActualLesson(les_id, dt, quantity, day);
                al.insertActualLesson();
            }

            start_date = start_date.AddDays(7);
            dt         = start_date.ToString("yyyy-MM-dd");

            checkTable.Clear();
            flg = 0;
        }

        string goodAlert = "";

        if (goodDatesList.Count >= 1)
        {
            if (goodDatesList.Count == 1)
            {
                goodAlert = "המופע שהתווסף לתגבור הנבחר חל בתאריך: " + goodDatesList[0] + ".";
            }
            else
            {
                goodAlert = "המופעים שהתווספו לתגבור הנבחר חלים בתאריכים הבאים: ";

                for (int j = 0; j < goodDatesList.Count; j++)
                {
                    if (j != (goodDatesList.Count - 1))
                    {
                        goodAlert += (goodDatesList[j] + ", ");
                    }
                    else
                    {
                        goodAlert += (goodDatesList[j] + ".");
                    }
                }
            }

            Session["goodAlert"] = goodAlert;
        }


        if (problemDatesList.Count >= 1)
        {
            string alert;
            if (problemDatesList.Count == 1)
            {
                alert = "לא ניתן להוסיף למערכת את תבנית התגבור שנבחרה בתאריך הבא: " + problemDatesList[0] + ". המתגבר משובץ לתגבור אחר בשעות התגבור שבחרת";
            }
            else
            {
                alert = "לא ניתן להוסיף את תבנית התגבור שנבחרה בתאריכים הבאים: ";

                for (int j = 0; j < problemDatesList.Count; j++)
                {
                    if (j != (problemDatesList.Count - 1))
                    {
                        alert += (problemDatesList[j] + ", ");
                    }
                    else
                    {
                        alert += (problemDatesList[j] + ".תהמתגבר משובץ כבר לתגבור אחר בתאריכים אלה בשעות התגבור שבחרת. ");
                    }
                }
            }
            if (Session["goodAlert"] != null)
            {
                alert += Convert.ToString(Session["goodAlert"]);
            }
            Session["alert"] = alert;
            //Response.Write(@"<script language='javascript'>alert('" + alert + "');</script>");
        }

        int    lessonCounter = goodDatesList.Count;
        string wantedCounter = counterTB.Text;

        Session["LessonCounterSession"] = goodDatesList.Count;
        Session["wantedCounter"]        = wantedCounter;
        Response.Redirect("ShowActualLesson_admin.aspx");
    }
Exemple #9
0
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        teachersRequests req   = new teachersRequests();
        GridViewRow      gvRow = (GridViewRow)(sender as Control).Parent.Parent;
        int index   = gvRow.RowIndex;
        int req_num = Convert.ToInt32(gvRow.Cells[1].Text);
        int status  = 1;

        int            cancelled = 1;
        ActualLesson   acl       = new ActualLesson();
        SignedToLesson stl       = new SignedToLesson();
        int            lesId     = Convert.ToInt32(gvRow.Cells[2].Text);
        DateTime       tmpDate   = Convert.ToDateTime(gvRow.Cells[3].Text);
        string         lesDate   = tmpDate.ToString("yyyy-MM-dd");
        Request        stuReq    = new Request();

        string proff = gvRow.Cells[4].Text;
        string start = gvRow.Cells[6].Text;

        Session["cancelledLesId"]   = lesId;
        Session["cancelledLesDate"] = lesDate;
        string    lesDateMES  = tmpDate.ToString("dd-MM-yyyy");
        Manager   m           = (Manager)(Session["manUserSession"]);
        double    manID       = m.Man_id;
        DataTable dt          = this.GetStudents();
        string    currnetDate = DateTime.Now.ToString("yyyy-MM-dd");
        Messages  mes;


        DataTable teaIDtable      = this.GetTeaId();
        double    teaID           = Convert.ToDouble(teaIDtable.Rows[0]["Les_Tea_Id"]);
        string    mesToTeaContent = "מתגבר יקר, בקשתך לביטול שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " אושרה והתגבור בוטל.";
        // Messages TeaMes = new Messages(manID, teaID, "ביטול שיעור", mesToTeaContent, false, currnetDate);
        Messages TeaMes = new Messages();

        TeaMes.Msg_fromManagerId = manID;
        TeaMes.Msg_toTeacherId   = teaID;
        TeaMes.Msg_subject       = "ביטול שיעור";
        TeaMes.Msg_content       = mesToTeaContent;
        TeaMes.Msg_hasRead       = false;
        TeaMes.Msg_date          = currnetDate;
        int numEffected1 = TeaMes.InsertMessageFromManagerToTeacher();

        string mesContent = "תלמיד יקר, שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " בוטל.";

        foreach (DataRow dr in dt.Rows)
        {
            double stuID = Convert.ToDouble(dr["StLes_stuId"]);

            mes = new Messages(manID, stuID, "ביטול שיעור", mesContent, false, currnetDate);
            int NumEffected = mes.InsertMessage();
        }


        try
        {
            int numEffected  = req.updateSpecificTeacherRequest(req_num, status);
            int numEffected2 = acl.cancelSpecificActualLesson(lesId, lesDate, cancelled);
            int numEffected3 = stl.deleteStudentsFromLesson(lesId, lesDate);
            int numEffected4 = stuReq.deleteCancelldLessonRequests(lesId, lesDate);
            Server.TransferRequest(Request.Url.AbsolutePath, false);
        }

        catch (Exception ex)
        {
            Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message);
            return;
        }
    }
    public void updateInDB(double id, int updateIsEntitledTo)
    {
        int     countOfmissingForStudent;
        Student stud = new Student();

        if (Convert.ToBoolean(Session["transferBack"]) == true)
        {
            try
            {
                DataTable dt = stud.readSpecipicStudent(id);
                foreach (DataRow row in dt.Rows)
                {
                    countOfmissingForStudent = Convert.ToInt32(row["stu_counter"]);
                    if (countOfmissingForStudent == 5)
                    {
                        stud.updateStu_CounterToZero(id);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("There was an error when trying to update stu_counter in the database" + ex.Message);
            }

            try
            {
                int numEffected = stud.updateIsEntittled(id, updateIsEntitledTo);
            }
            catch (Exception ex)
            {
                Response.Write("There was an error when trying to update stu_isEntitled in the database" + ex.Message);
            }
        }

        else
        {
            try
            {
                int     numEffected = stud.updateIsEntittled(id, updateIsEntitledTo);
                Request req         = new Request();
                int     numEf       = req.deleteRequests(id); // מחיקת כל הבקשות שלו להרשמה לתגבורים שעוד לא עברו

                SignedToLesson delStu = new SignedToLesson();
                Session["entStu"] = id;
                //נביא את כל התגבורים שבהם התלמיד משתתף ותאריך התגבור עוד לא עבר ונמחק את התלממיד מתגבורים אלה
                DataTable classesForStuIdDT = this.GetClassForStu();
                foreach (DataRow ro in classesForStuIdDT.Rows)
                {
                    DateTime dat = (DateTime)(ro["StLes_ActLesDate"]);
                    if (dat >= DateTime.Now)
                    {
                        string       da     = dat.ToString("yyyy-MM-dd");
                        int          lesNum = Convert.ToInt32(ro["StLes_ActLesId"]);
                        int          numEf1 = delStu.deleteStudentFromLesson(id, lesNum, da);
                        ActualLesson actls  = new ActualLesson();
                        int          numEfc = actls.reduceQuan(lesNum, da);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("There was an error when trying to update stu_isEntitled in the database" + ex.Message);
            }
        }
    }
    protected void reqGV_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[8].Text == "1")
            {
                e.Row.Cells[8].Text = "א'";
            }
            else if (e.Row.Cells[8].Text == "2")
            {
                e.Row.Cells[8].Text = "ב'";
            }
            else if (e.Row.Cells[8].Text == "3")
            {
                e.Row.Cells[8].Text = "ג'";
            }
            else if (e.Row.Cells[8].Text == "4")
            {
                e.Row.Cells[8].Text = "ד'";
            }
            else // יום חמישי
            {
                e.Row.Cells[8].Text = "ה'";
            }


            if (e.Row.Cells[14].Text == "1")
            {
                e.Row.Cells[14].Text = "אושרה";
            }

            else if (e.Row.Cells[14].Text == "0")
            {
                e.Row.Cells[14].Text = "נדחתה";
            }

            else
            {
                e.Row.Cells[14].Text = "ממתינה";
            }


            if (e.Row.Cells[2].Text == "0")
            {
                e.Row.Cells[2].Text = "הרשמה לתגבור";
            }

            else if (e.Row.Cells[2].Text == "1")
            {
                e.Row.Cells[2].Text = "ביטול השתתפות";
            }
            else
            {
                e.Row.Cells[2].Text = "";
            }
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int index = e.Row.Cells[7].Text.IndexOf(" ");
            e.Row.Cells[7].Text = e.Row.Cells[7].Text.Substring(0, index);
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[14].Text != "ממתינה")
            {
                Button statusAp = (Button)e.Row.FindControl("AproveButton");
                statusAp.Visible = false;
                Button statusDe = (Button)e.Row.FindControl("DeclineButton");
                statusDe.Visible = false;
            }
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[2].Text != "ביטול השתתפות")
            {
                if ((Convert.ToInt32(e.Row.Cells[13].Text) == (Convert.ToInt32(e.Row.Cells[12].Text))) && e.Row.Cells[14].Text == "ממתינה")
                {
                    Server.TransferRequest(Request.Url.AbsolutePath, false);

                    ActualLesson acl     = new ActualLesson();
                    double       stuId   = Convert.ToDouble(e.Row.Cells[3].Text);
                    int          lesId   = Convert.ToInt32(e.Row.Cells[5].Text);
                    DateTime     tmpDate = Convert.ToDateTime(e.Row.Cells[7].Text);
                    string       lesDate = tmpDate.ToString("yyyy-MM-dd");
                    Request      req     = new Request();

                    int req_num = Convert.ToInt32(e.Row.Cells[1].Text);

                    Session["lessonId"]   = lesId;
                    Session["lessonDate"] = lesDate;
                    string proffTitle = e.Row.Cells[6].Text;
                    Session["proffTitle"] = proffTitle;

                    string   LesDateFormat = tmpDate.ToString("dd/MM/yyyy");
                    string   currnetDate   = DateTime.Now.ToString("yyyy-MM-dd");
                    Messages mes;
                    Manager  m                = (Manager)(Session["manUserSession"]);
                    double   manID            = m.Man_id;
                    string   selectedLesSHour = e.Row.Cells[9].Text;

                    DataTable dt = this.GetAlternativeActualLesson();
                    if (dt != null)
                    {
                        //first alternative
                        //string firstAlternativeProff = Convert.ToString(dt.Rows[0]["Pro_Title"]);
                        if (dt.Rows.Count == 2)
                        {
                            DateTime tempFirstAlternativeDate = Convert.ToDateTime(dt.Rows[0]["actLes_date"]);
                            string   firstAlternativeDate     = tempFirstAlternativeDate.ToString("dd/MM/yyyy");
                            string   firstAlternativeSHour    = Convert.ToString(dt.Rows[0]["Les_StartHour"]);
                            //string firstAlternativeEHour = Convert.ToString(dt.Rows[0]["Les_EndHour"]);
                            int    firstAlternativeIntDay = Convert.ToInt32(dt.Rows[0]["Les_day"]);
                            string firstAlternativeDay;
                            if (firstAlternativeIntDay == 1)
                            {
                                firstAlternativeDay = "ראשון";
                            }
                            else if (firstAlternativeIntDay == 2)
                            {
                                firstAlternativeDay = "שני";
                            }
                            else if (firstAlternativeIntDay == 3)
                            {
                                firstAlternativeDay = "שלישי";
                            }
                            else if (firstAlternativeIntDay == 4)
                            {
                                firstAlternativeDay = "רביעי";
                            }
                            else
                            {
                                firstAlternativeDay = "חמישי";
                            }

                            //second alternative
                            //string secondAlternativeProff = Convert.ToString(dt.Rows[1]["Pro_Title"]);//לא צריך כי אותה מספר תגבור זה אותו מזהה מקצוע והשאילתא לפי מספר תגבור
                            DateTime tempSecondAlternativeDate = Convert.ToDateTime(dt.Rows[1]["actLes_date"]);
                            string   secondAlternativeDate     = tempSecondAlternativeDate.ToString("dd/MM/yyyy");
                            string   secondAlternativeSHour    = Convert.ToString(dt.Rows[1]["Les_StartHour"]);
                            //string secondAlternativeEHour = Convert.ToString(dt.Rows[1]["Les_EndHour"]);
                            int    secondAlternativeIntDay = Convert.ToInt32(dt.Rows[1]["Les_day"]);
                            string secondAlternativeDay;
                            if (secondAlternativeIntDay == 1)
                            {
                                secondAlternativeDay = "ראשון";
                            }
                            else if (secondAlternativeIntDay == 2)
                            {
                                secondAlternativeDay = "שני";
                            }
                            else if (secondAlternativeIntDay == 3)
                            {
                                secondAlternativeDay = "שלישי";
                            }
                            else if (secondAlternativeIntDay == 4)
                            {
                                secondAlternativeDay = "רביעי";
                            }
                            else
                            {
                                secondAlternativeDay = "חמישי";
                            }


                            //string mesContent = "תלמיד יקר, שיעור " + proffTitle + " שחל בתאריך " + LesDateFormat + ", בשעה " + selectedLesSHour + " מלא. באפשרותך להירשם לאחד המתגבורים הבאים: " + "<br><br>" + proffTitle + " " + firstAlternativeDate + ", יום " + firstAlternativeDay + ", משעה " + firstAlternativeSHour + " עד " + firstAlternativeEHour + "<br>" + proffTitle + " " + secondAlternativeDate + ", יום " + secondAlternativeDay + " משעה " + secondAlternativeSHour + " עד " + secondAlternativeEHour;
                            string mesContent = "תלמיד יקר, שיעור " + proffTitle + " שחל בתאריך " + LesDateFormat + ", בשעה " + selectedLesSHour + " מלא. באפשרותך להירשם לאחד המתגבורים הבאים: " + "<br><br>" + proffTitle + " " + firstAlternativeDate + ", יום " + firstAlternativeDay + ", בשעה " + firstAlternativeSHour + "<br>" + proffTitle + " " + secondAlternativeDate + ", יום " + secondAlternativeDay + " בשעה " + secondAlternativeSHour;
                            mes = new Messages(manID, stuId, "בקשתך להירשם לתגבור נדחתה", mesContent, false, currnetDate);
                            int NumEffected = mes.InsertMessage();
                        }

                        else if (dt.Rows.Count == 1)
                        {
                            DateTime tempFirstAlternativeDate = Convert.ToDateTime(dt.Rows[0]["actLes_date"]);
                            string   firstAlternativeDate     = tempFirstAlternativeDate.ToString("dd/MM/yyyy");
                            string   firstAlternativeSHour    = Convert.ToString(dt.Rows[0]["Les_StartHour"]);
                            string   firstAlternativeEHour    = Convert.ToString(dt.Rows[0]["Les_EndHour"]);
                            int      firstAlternativeIntDay   = Convert.ToInt32(dt.Rows[0]["Les_day"]);
                            string   firstAlternativeDay;
                            if (firstAlternativeIntDay == 1)
                            {
                                firstAlternativeDay = "ראשון";
                            }
                            else if (firstAlternativeIntDay == 2)
                            {
                                firstAlternativeDay = "שני";
                            }
                            else if (firstAlternativeIntDay == 3)
                            {
                                firstAlternativeDay = "שלישי";
                            }
                            else if (firstAlternativeIntDay == 4)
                            {
                                firstAlternativeDay = "רביעי";
                            }
                            else
                            {
                                firstAlternativeDay = "חמישי";
                            }

                            string mesContent = "תלמיד יקר, שיעור " + proffTitle + " שחל בתאריך " + LesDateFormat + ", בשעה " + selectedLesSHour + " מלא. באפשרותך להירשם לתגבור הבא: " + proffTitle + " שחל בתאריך " + firstAlternativeDate + ", ביום " + firstAlternativeDay + " החל מהשעה " + firstAlternativeSHour + " ועד שעה " + firstAlternativeEHour;
                            mes = new Messages(manID, stuId, "בקשתך להירשם לתגבור נדחתה", mesContent, false, currnetDate);
                            int NumEffected = mes.InsertMessage();
                        }
                    }
                    else//אם אין תגבורים מתאימים (בעתיד) כרגע
                    {
                        string mesContent = "תלמיד יקר, שיעור " + proffTitle + " שחל בתאריך " + LesDateFormat + ", בשעה " + selectedLesSHour + " מלא ולכן לא ניתן להירשם לתגבור. עמך הסליחה";
                        mes = new Messages(manID, stuId, "בקשתך להירשם לתגבור נדחתה", mesContent, false, currnetDate);
                        int NumEffected = mes.InsertMessage();
                    }
                    int status      = 0;
                    int decFull     = 1;
                    int numEffected = req.updateSpecificRequest(req_num, status);
                    int numEff      = req.updateDecfullField(req_num, decFull);
                }
            }
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DateTime currentDate = DateTime.Now.Date;
            DateTime lesDate     = Convert.ToDateTime(e.Row.Cells[7].Text);
            if (lesDate < currentDate && e.Row.Cells[14].Text == "ממתינה")
            {
                int     reqId       = Convert.ToInt32(e.Row.Cells[1].Text);
                Request req         = new Request();
                int     status      = 0; // נדחה אוטומטית בקשות ממתינות לתגבור שכבר עבר
                int     numEffected = req.updateSpecificRequest(reqId, status);
            }

            //if (lesDate < currentDate)// לא נציג בקשות לתגבור שכבר עבר
            //{
            //    e.Row.Visible = false;
            //}
        }
    }
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        Session["flgSendReq"] = "1";
        Request     req     = new Request();
        GridViewRow gvRow   = (GridViewRow)(sender as Control).Parent.Parent;
        int         req_num = Convert.ToInt32(gvRow.Cells[1].Text);

        ActualLesson   acl = new ActualLesson();
        SignedToLesson stl;
        double         stuId   = Convert.ToDouble(gvRow.Cells[3].Text);
        int            lesId   = Convert.ToInt32(gvRow.Cells[5].Text);
        DateTime       tmpDate = Convert.ToDateTime(gvRow.Cells[7].Text);
        string         lesDate = tmpDate.ToString("yyyy-MM-dd");

        int    req_type     = 1;
        string req_typeName = gvRow.Cells[2].Text;

        if (req_typeName != "ביטול השתתפות")
        {
            req_type = 0;
        }
        else //נאשר בקשה לביטול השתתפות- נשנה סטטוס בקשה ל-1
        {
            int status      = 1;
            int numEffected = req.updateSpecificRequest(req_num, status);

            try
            {
                stl = new SignedToLesson(lesId, lesDate, stuId);
            }
            catch (Exception ex)
            {
                Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message);
                return;
            }

            int actual_quan = Convert.ToInt32(gvRow.Cells[13].Text) - 1;

            try
            {
                int numEffected3 = acl.updateSpecificActualLesson(lesId, lesDate, actual_quan); //הקטנת כמות משתתפים ב-1
                int numEffected2 = stl.deleteStudentFromLesson(stuId, lesId, lesDate);          //הוצאת התלמיד מטבלת "רשום לתגבור"
                Server.TransferRequest(Request.Url.AbsolutePath, false);
            }
            catch (Exception ex)
            {
                Response.Write("There was an error " + ex.Message);
            }
        }

        int       flg        = 0; //מסמן שאין התנגשות בין תגבור מבוקש לבין תגבור אחר כלשהו שהתלמיד משובץ אליו
        DataTable checkTable = new DataTable();

        checkTable.Columns.Add("flg", typeof(int)); //מסמן אם ניתן להוסיף תגבור או לא- 1 ניתן 0 לא ניתן

        if (req_type != 1)                          //אם זו בקשה להרשמה (זו לא בקשה לביטול השתתפות)
        {
            //ניקח את שעות התגבור המבוקש ע"מ לראות אם באותם שעות בתאריך התגבור, התלמיד משובץ לתגבור אחר
            DateTime reqLesStart = DateTime.Parse((gvRow.Cells[9].Text).ToString());
            DateTime reqLesEnd   = DateTime.Parse((gvRow.Cells[10].Text).ToString());

            Session["reqStuId"]   = stuId;
            Session["reqLesDate"] = lesDate;

            //נביא את כל התגבורים (תאריך+שעת התחלה+שעת סיום+מס תגבור) עבור מתגבר זה
            DataTable DTclassForReqStuId = this.GetClassForReqStuId();
            if (DTclassForReqStuId.Rows.Count > 0)//המשמעות שהתלמיד המבקש משובץ לתגבורים אחרים בתאריך המבוקש- נבדוק התנגשות בשעות
            {
                foreach (DataRow dr in DTclassForReqStuId.Rows)
                {
                    //אם יש לו תגבור באותו יום, אבל התגבור הנבחר מתחיל ומסתיים לפני התגבורים אחרים שיש לו באותו יום- ניתן לשבץ
                    if (reqLesStart < DateTime.Parse((dr["Les_StartHour"]).ToString()) && reqLesEnd <= DateTime.Parse((dr["Les_StartHour"]).ToString()))
                    {
                        DataRow newRow = checkTable.NewRow();
                        // Set values in the columnn:
                        newRow["flg"] = 1;
                        // Add the row to the rows collection.
                        checkTable.Rows.Add(newRow);
                    }
                    //אם יש לו תגבור באותו יום, אבל התגבור הנבחר מתחיל אחרי שהתגבורים אחרים שיש לו באותו יום כבר התחילו והסתיימו- ניתן לשבץ
                    else if (reqLesStart > DateTime.Parse((dr["Les_StartHour"]).ToString()) && reqLesStart >= DateTime.Parse((dr["Les_EndHour"]).ToString()))
                    {
                        DataRow newRow = checkTable.NewRow();
                        // Set values in the column
                        newRow["flg"] = 1;
                        // Add the row to the rows collection.
                        checkTable.Rows.Add(newRow);
                    }
                    else //כל מצב אחר המשמעות שיש תגבור לתלמיד באותו התאריך וגם השעות מתנגשות
                    {
                        DataRow newRow = checkTable.NewRow();
                        // Set values in the column
                        newRow["flg"] = 0;
                        // Add the row to the rows collection.
                        checkTable.Rows.Add(newRow);
                    }
                }
            }

            if (checkTable.Rows.Count > 0)
            {
                foreach (DataRow dr in checkTable.Rows)
                {
                    if (Convert.ToInt32(dr["flg"]) != 1)
                    {
                        flg = 1;
                        break;//מספיק שלפחות אחד מהתגבורים בתאריך זה מתנגש עם שעות התגבור הנבחר
                    }
                }
            }

            if (flg == 0)                                                                            //אין התנגשות, אז נבדוק האם יש מקום בתגבור ואם כן נאשר
            {
                if (Convert.ToInt32(gvRow.Cells[13].Text) < (Convert.ToInt32(gvRow.Cells[12].Text))) //אם יש מקום בתגבור הבקשה תאושר והתלמיד נרשם לתגבור
                {
                    int status      = 1;
                    int numEffected = req.updateSpecificRequest(req_num, status);

                    try
                    {
                        stl = new SignedToLesson(lesId, lesDate, stuId);
                    }
                    catch (Exception ex)
                    {
                        Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message);
                        return;
                    }

                    int actual_quan = Convert.ToInt32(gvRow.Cells[13].Text) + 1;



                    try
                    {
                        int numEffected3 = acl.updateSpecificActualLesson(lesId, lesDate, actual_quan); //הגדלת כמות משתתפים ב-1
                        int numEffected2 = stl.InsertSigendToLesson();                                  //הכנסת התלמיד לטבלת "רשום לתגבור"
                        Server.TransferRequest(Request.Url.AbsolutePath, false);
                    }
                    catch (Exception ex)
                    {
                        Response.Write("There was an error " + ex.Message);
                    }
                }
            }
            else //התלמיד משובץ כבר לתגבור אחר שמתנגש עם התגבור המבוקש- נדחה את הבקשה עם סיבת דחייה לתלמיד ואלרט למנהלת
            {
                int status       = 0;
                int Decliend     = 1;
                int numEffected  = req.updateSpecificRequest(req_num, status);    //נעדכן שהבקשה נדחתה
                int numEffected4 = req.updateReqDecliendField(req_num, Decliend); //נעדכן שהסיבה לדחיית הבקשה היא "אילוץ" ההתנגשות


                string   proffTitle    = gvRow.Cells[6].Text;
                string   start         = gvRow.Cells[9].Text;
                string   LesDateFormat = tmpDate.ToString("dd/MM/yyyy");
                string   currnetDate   = DateTime.Now.ToString("yyyy-MM-dd");
                Messages mes;
                Manager  m     = (Manager)(Session["manUserSession"]);
                double   manID = m.Man_id;


                string mesContent = "תלמיד יקר, שיעור " + proffTitle + " שחל בתאריך " + LesDateFormat + ", בשעה " + reqLesStart.ToString("HH:mm") + " מתנגש עם תגבור אחר שאתה משובץ אליו בתאריך זה";
                mes = new Messages(manID, stuId, "בקשתך להירשם לתגבור נדחתה", mesContent, false, currnetDate);
                int NumEffected = mes.InsertMessage();


                Session["declineReq"] = true;
                Server.TransferRequest(Request.Url.AbsolutePath, false);
            }
        }
    }
Exemple #13
0
    protected void updateForm_Click(object sender, EventArgs e)
    {
        int       lessID   = Convert.ToInt32(Session["selectedLessonNum"]);
        string    lesDate  = (string)(Session["selectedLessonDate"]);
        DateTime  lessDate = Convert.ToDateTime(lesDate);
        DataTable dt       = (DataTable)(Session["studentsList"]);

        foreach (DataRow dr in dt.Rows)
        {
            double   Stu_id = Convert.ToDouble(dr["StLes_stuId"]);
            CheckBox cb     = (CheckBox)PlaceHolder1.FindControl("cb" + Stu_id.ToString());
            if (cb != null)
            {
                if (cb.Checked == false)
                {
                    int            stuPresence = 0;
                    SignedToLesson stl         = new SignedToLesson();
                    stl.updateStudentPresence(lessID, lessDate, Stu_id, stuPresence);
                    Student stud = new Student();
                    stud.updateStudentCounter(Stu_id);
                    DataTable dtCounter = stud.getStudentCounter(Stu_id);
                    DataTable manDT     = this.GetManeger();

                    foreach (DataRow drMan in manDT.Rows)
                    {
                        double msg_toManagerId = Convert.ToDouble(drMan["Man_Id"]);
                        Session["msg_toManagerId"] = msg_toManagerId;
                    }


                    bool     msg_has_read = false;
                    DateTime msg_date     = DateTime.Now;

                    foreach (DataRow d in dtCounter.Rows)
                    {
                        if (Convert.ToInt32(d[0]) == 5)//להכניס את התלמיד לרשימת הלא זכאים
                        {
                            int      updateIsEntitledTo = 0;
                            string   currnetDate        = DateTime.Now.ToString("yyyy-MM-dd");
                            Messages mes;
                            double   msg_ManagerId = Convert.ToDouble(Session["msg_toManagerId"]);

                            string mesContent = "תלמיד יקר, עקב אי הגעתך לתגבורים אינך זכאי להגיש בקשות. אנא פנה למנהל/ת";
                            mes = new Messages(msg_ManagerId, Stu_id, "עדכון זכאות לתגבורים", mesContent, false, currnetDate);

                            Messages messageForStudent = new Messages();
                            messageForStudent.Msg_fromStudentId = Stu_id;
                            messageForStudent.Msg_toManagerId   = msg_ManagerId;
                            messageForStudent.Msg_subject       = "עדכון זכאות- הודעת מערכת";
                            messageForStudent.Msg_content       = " זוהי הודעה אוטומטית: המערכת הכניסה את תלמיד זה לרשימת הלא זכאים, עקב אי הגעתו לתגבורים. באפשרותך להוציא אותו מהרשימה";
                            messageForStudent.Msg_hasRead       = msg_has_read;
                            messageForStudent.System_msg        = 1;
                            messageForStudent.Msg_date          = msg_date.ToString("yyyy-MM-dd");

                            string date = lessDate.ToString("yyyy-MM-dd");
                            Session["entStu"] = Stu_id;
                            try
                            {
                                Request req          = new Request();
                                int     numEf        = req.deleteRequests(Stu_id); // מחיקת כל הבקשות שלו להרשמה לתגבורים שעוד לא עברו
                                int     numEffected  = stud.updateIsEntittled(Stu_id, updateIsEntitledTo);
                                int     NumEffected2 = mes.InsertMessage();


                                int            numEffected11 = messageForStudent.InsertMessageSystemStudent();
                                SignedToLesson delStu        = new SignedToLesson();
                                //int numEf1 = delStu.deleteStudentFromLesson(Stu_id, lessID, date);

                                //נביא את כל התגבורים שבהם התלמיד משתתף ותאריך התגבור עוד לא עבר ונמחק את התלממיד מתגבורים אלה
                                DataTable classesForStuIdDT = this.GetClassForStu();
                                foreach (DataRow ro in classesForStuIdDT.Rows)
                                {
                                    DateTime dat = (DateTime)(ro["StLes_ActLesDate"]);
                                    if (dat >= DateTime.Now)
                                    {
                                        string       da     = dat.ToString("yyyy-MM-dd");
                                        int          lesNum = Convert.ToInt32(ro["StLes_ActLesId"]);
                                        int          numEf1 = delStu.deleteStudentFromLesson(Stu_id, lesNum, da);
                                        ActualLesson actl   = new ActualLesson();
                                        int          quan   = actl.readSpecificActualLessonQuan(lesNum, da) - 1;
                                        int          numEfc = actl.updateSpecificActualLesson(lesNum, da, quan);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Response.Write("There was an error when trying to insert the product into the database" + ex.Message);
                            }
                        }
                    }
                }
                else
                {
                    int            stuPresence = 1;
                    SignedToLesson stl         = new SignedToLesson();
                    stl.updateStudentPresence(lessID, lessDate, Stu_id, stuPresence);
                }
            }
            TextBox tb = (TextBox)PlaceHolder1.FindControl("tb" + Stu_id.ToString());
            if (tb != null)
            {
                string         stuNotes = tb.Text;
                SignedToLesson stl      = new SignedToLesson();
                stl.updateStudentNotes(lessID, lessDate, Stu_id, stuNotes);
            }
            Session["updateForm"] = true;
        }

        Response.Redirect("ClassesForTeacher.aspx");
    }