Ejemplo n.º 1
0
        protected override void OnUpdate(ModelElementBase modelElement)
        {
            Machine machine = (Machine)modelElement;

            Lot lot = machine.LotInService;

            string type = lot.ProductType;

            //Writer?.WriteLine($"{machine.GetTime},{lot.EndTime - lot.StartTime},{lot.Id},{lot.ProductType},{lot.EndTime},{lot.StartTime}");
            ExperimentWriter?.WriteLine($"{replicationCounter},{machine.GetTime},{lot.EndTime - lot.StartTime},{lot.Id},{lot.ProductType},{lot.EndTime},{lot.StartTime},{lot.Lateness}");
            lotCounter++;

            if (!Lateness.ContainsKey(type))
            {
                Lateness.Add(lot.ProductType, new Statistic("Lateness"));
                Tardiness.Add(lot.ProductType, new Statistic("Lateness"));
                Earliness.Add(lot.ProductType, new Statistic("Lateness"));
            }

            Lateness[type].Collect(lot.Lateness);

            if (lot.Lateness > 0)
            {
                Tardiness[type].Collect(lot.Lateness);
            }
            else
            {
                Earliness[type].Collect(lot.Lateness);
            }
        }
Ejemplo n.º 2
0
        public void ListTimesheetWithLateness(int nEmployeeID, string strBranchCode, Month aMonth, int aYear)
        {
            DateTime startDate, endDate;

            ACMSLogic.Staff.Ultis.DatesRange(out startDate, out endDate, aMonth, aYear);
            DataTable myRosterTable = ListTimesheet(nEmployeeID, strBranchCode, startDate, endDate);

            //			if (!myRosterTable.Columns.Contains("nRosterID"))
            //				throw new Exception("Missing 'nRosterID' at Sv_Staff_Timesheet view.");

            //myRosterTable.PrimaryKey = new DataColumn[] {myRosterTable.Columns["nRosterID"]};
            myRosterTable.DefaultView.Sort = "dtDate";

            Lateness myLateness = new Lateness();

            myLateness.GetLateness(nEmployeeID, aMonth, aYear);
            DataTable myLatenessTable = myLateness.LatenessTable;

            foreach (DataRow rLateness in myLatenessTable.Rows)
            {
                if (Convert.ToDateTime(rLateness["dtDate"]) >= DateTime.Now)
                {
                    continue;
                }
                //DataRow rRoster = myRosterTable.Rows.Find(rLateness["nRosterID"]);
                DataRow[] rRoster = myRosterTable.Select("nRosterID = '" + rLateness["nRosterID"] + "'");
                //if (rRoster != null && rRoster.Length >= 1)
                foreach (DataRow r in rRoster)
                {
                    r.BeginEdit();
                    r["fLateness"]  = true;
                    r["nLateness"]  = ACMS.Convert.ToInt32(r["nLateness"]) + ACMS.Convert.ToInt32(rLateness["nLateness"]);
                    r["dtLateness"] = DateTime.Today.AddMinutes(ACMS.Convert.ToInt32(r["nLateness"]));
                    r.EndEdit();
                }
            }
            myMasterTable = myRosterTable;
            myDetailTable.Clear();
        }
Ejemplo n.º 3
0
    protected void btnsave_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            SchoolInformation info   = new SchoolInformation();
            MyDate            mydate = new MyDate();

            foreach (ListViewItem item in ListView1.Items)
            {
                Button btnActive = (Button)item.FindControl("btnActive");
                if (btnActive.Text == "غياب")
                {
                    Absence abs = new Absence();
                    abs.SemesterId = MyDate.getCurrentSemesterId();
                    abs.SchoolId   = info.getId();
                    var empId = ((HiddenField)item.FindControl("HiddenField1")).Value.ToString();
                    abs.EmployeeId = empId;
                    if (Calendar1.CultureName == "ar-SA")
                    {
                        abs.Date = MyDate.convertHijriToGregorian(datepicker.Text);
                    }
                    else
                    {
                        abs.Date = DateTime.ParseExact(datepicker.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("ar-EG"));
                    }

                    abs.Type = int.Parse(((DropDownList)item.FindControl("lstResonLate")).SelectedValue);

                    var today = DateTime.Now.DayOfWeek;

                    var schoolid = info.getId();

                    DateTime yesterday = DateTime.Now.AddDays(-1).Date;
                    if (today == DayOfWeek.Sunday)
                    {
                        yesterday = DateTime.Now.AddDays(-3).Date;
                    }

                    var absentYesterday = ((from k in km.Absences where k.EmployeeId == empId && k.Date == yesterday select k).FirstOrDefault());
                    if (absentYesterday != null)
                    {
                        AbsenceAlert alert = (from k in km.AbsenceAlerts where k.Id == absentYesterday.AlertId select k).FirstOrDefault();
                        alert.DateTo = DateTime.Now;
                        abs.AlertId  = alert.Id;
                        alert.count++;
                        if (today == DayOfWeek.Sunday)
                        {
                            alert.countHoliday = alert.countHoliday + 2;
                        }
                    }
                    else
                    {
                        AbsenceAlert alert = new AbsenceAlert();
                        alert.SemesterId   = MyDate.getCurrentSemesterId();
                        alert.SchoolId     = info.getId();
                        alert.EmployeeId   = empId;
                        alert.DateFrom     = DateTime.Now;
                        alert.DateTo       = DateTime.Now;
                        alert.count        = 1;
                        alert.countHoliday = 0;
                        km.AbsenceAlerts.Add(alert);
                        km.SaveChanges();

                        abs.AlertId = alert.Id;
                    }

                    lstAbs.Add(abs);
                    km.Absences.Add(abs);
                    km.SaveChanges();
                }
                else if (btnActive.Text == "حضور")
                {
                    Attendence att = new Attendence();
                    att.Date = DateTime.Now;
                    var schoolId = info.getId();
                    att.SchoolId   = schoolId;
                    att.SemesterId = MyDate.getCurrentSemesterId();
                    att.EmployeeId = ((HiddenField)item.FindControl("HiddenField1")).Value;
                    TextBox txtArrive = (TextBox)item.FindControl("txtarrivingTime");
                    if (!String.IsNullOrEmpty(txtArrive.Text))
                    {
                        att.ArrivingTime = Convert.ToDateTime(txtArrive.Text).TimeOfDay;
                    }
                    TextBox txtDeparture = (TextBox)item.FindControl("txtdeptime");
                    if (!String.IsNullOrEmpty(txtDeparture.Text))
                    {
                        TimeSpan departure   = Convert.ToDateTime(txtDeparture.Text).TimeOfDay;
                        var      timeWorkEnd = (from k in km.Schools where k.Id == schoolId select k.TimeEndWork).FirstOrDefault();
                        var      amount      = timeWorkEnd - departure;
                        if (amount.TotalSeconds > 0)
                        {
                            Lateness late = new Lateness();
                            late.Amount       = amount;
                            late.TotalSeconds = amount.TotalSeconds;
                            late.IsPrinted    = false;
                            late.Type         = ConstantManager.getConstantId("انصراف مبكر");
                            late.SchoolId     = schoolId;
                            late.SemesterId   = MyDate.getCurrentSemesterId();
                            late.Date         = DateTime.Now.Date;
                            late.EmployeeId   = ((HiddenField)item.FindControl("HiddenField1")).Value;
                            km.Latenesses.Add(late);
                        }
                        att.DepartureTime = departure;
                    }

                    km.Attendences.Add(att);
                    km.SaveChanges();
                }
                else if (btnActive.Text == "تأخر")
                {
                    Lateness late = new Lateness();

                    if (!String.IsNullOrEmpty(((TextBox)item.FindControl("TimeLate")).Text))
                    {
                        var schoolId = info.getId();

                        TimeSpan timearrive    = Convert.ToDateTime(((TextBox)item.FindControl("TimeLate")).Text).TimeOfDay;
                        TimeSpan timestartwork = (TimeSpan)(from k in km.Schools where k.Id == schoolId select k.TimeStartWork).FirstOrDefault();
                        TimeSpan amount        = timearrive - timestartwork;
                        if (amount.TotalSeconds > 0)
                        {
                            late.TotalSeconds = amount.TotalSeconds;
                            late.Type         = ConstantManager.getConstantId("تأخر صباحي");
                            late.Amount       = amount;
                            late.Date         = DateTime.Now;
                            late.SchoolId     = info.getId();
                            late.SemesterId   = MyDate.getCurrentSemesterId();
                            var empId = ((HiddenField)item.FindControl("HiddenField1")).Value;
                            late.EmployeeId = empId;
                            km.Latenesses.Add(late);
                            var year = DateTime.Now.Year;

                            var lateSum = (from k in km.Latenesses
                                           where k.EmployeeId == empId && k.Date.Value.Year == year
                                           select k.TotalSeconds).Sum();

                            if (lateSum != null)
                            {
                                var total = lateSum + late.TotalSeconds;

                                var currentLate = (int)lateSum / 3600;
                                var totalLate   = (int)total / 3600;

                                if (totalLate >= 7 && totalLate > currentLate)
                                {
                                    //اضافة حسم
                                    LatenessDecision alertdecition = new LatenessDecision();
                                    alertdecition.SchoolId   = info.getId();
                                    alertdecition.SemesterId = MyDate.getCurrentSemesterId();
                                    alertdecition.Date       = DateTime.Now.Date;
                                    alertdecition.Days       = 1;
                                    alertdecition.EmployeeId = empId;
                                    alertdecition.Hours      = totalLate;
                                    km.LatenessDecisions.Add(alertdecition);
                                }
                                else
                                if (totalLate >= 3 && totalLate > currentLate)
                                {
                                    //اضافة تنبيه
                                    LatenessDecision alertdecition = new LatenessDecision();
                                    alertdecition.SchoolId   = info.getId();
                                    alertdecition.SemesterId = MyDate.getCurrentSemesterId();
                                    alertdecition.Date       = DateTime.Now.Date;
                                    alertdecition.Days       = 0;
                                    alertdecition.EmployeeId = empId;
                                    alertdecition.Hours      = totalLate;
                                    km.LatenessDecisions.Add(alertdecition);
                                }
                            }
                        }
                        else
                        {
                            Attendence att = new Attendence();
                            att.Date         = DateTime.Now;
                            att.SchoolId     = info.getId();
                            att.SemesterId   = MyDate.getCurrentSemesterId();
                            att.EmployeeId   = ((HiddenField)item.FindControl("HiddenField1")).Value;
                            att.ArrivingTime = timearrive;

                            km.Attendences.Add(att);
                        }
                    }
                    km.SaveChanges();
                }
            }

            Response.Redirect("~/EmployeeAttendence/AttendenceReport.aspx");
        }
    }
Ejemplo n.º 4
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        SchoolInformation Info = new SchoolInformation();
        var      SID           = Info.getId();
        var      SemId         = MyDate.getCurrentSemesterId();
        Lateness Late          = new Lateness();
        var      empId         = ddlNameEMp.SelectedValue;

        Late.EmployeeId = empId;
        if (Calendar1.CultureName == "ar-SA")
        {
            Late.Date = MyDate.convertHijriToGregorian(datepicker.Text);
        }
        else
        {
            Late.Date = DateTime.ParseExact(datepicker.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("ar-EG"));
        }

        Late.SchoolId   = SID;
        Late.SemesterId = SemId;
        var type = int.Parse(ddlType.SelectedValue);

        Late.Type = type;
        if (type == ConstantManager.getConstantId("خروج دون استئذان"))
        {
            Late.TimeFrom = Convert.ToDateTime(TextTimeFrom.Text).TimeOfDay;
            Late.Timeto   = Convert.ToDateTime(TextTimeTo.Text).TimeOfDay;

            Late.Amount       = Late.Timeto - Late.TimeFrom;
            Late.TotalSeconds = ((TimeSpan)Late.Amount).TotalSeconds;
        }
        else
        {
            Late.Amount       = new TimeSpan(0, int.Parse(txtamount.Text), 0);
            Late.TotalSeconds = (TimeSpan.Parse(Late.Amount.ToString())).TotalSeconds;
        }
        var year = DateTime.Now.Year;

        var lateSum = (from k in km.Latenesses
                       where k.EmployeeId == empId && k.Date.Value.Year == year
                       select k.TotalSeconds).Sum();

        if (lateSum != null)
        {
            var total = lateSum + Late.TotalSeconds;

            var currentLate = (int)lateSum / 3600;
            var totalLate   = (int)total / 3600;

            if (totalLate > 7 && totalLate > currentLate)
            {
                //اضافة حسم
                LatenessDecision alertdecition = new LatenessDecision();
                alertdecition.SchoolId   = Info.getId();
                alertdecition.SemesterId = MyDate.getCurrentSemesterId();
                alertdecition.Date       = DateTime.Now.Date;
                // alertdecition.Days=
                alertdecition.EmployeeId = empId;
                alertdecition.Hours      = totalLate;
                km.LatenessDecisions.Add(alertdecition);
            }
            else
            if (totalLate > 3 && totalLate > currentLate)
            {
                //اضافة تنبيه

                // LatenessAlert alert = new LatenessAlert();
                LatenessDecision alertdecition = new LatenessDecision();
                alertdecition.SchoolId   = Info.getId();
                alertdecition.SemesterId = MyDate.getCurrentSemesterId();
                alertdecition.Date       = DateTime.Now.Date;
                alertdecition.Days       = 0;
                alertdecition.EmployeeId = empId;
                alertdecition.Hours      = totalLate;
                km.LatenessDecisions.Add(alertdecition);
            }
        }
        clearText();
        km.Latenesses.Add(Late);
        km.SaveChanges();
        ClientScript.RegisterStartupScript(this.GetType(), "openModal", "<script> openModal(); </script>", false);
    }