protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        e.Item.FindControl("DeleteItem").Visible = IsAllowEdit;
        if (e.Item.ItemIndex == Repeater.EditItemIndex)
        {
            ebinding = new Binding(dbConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("AuthorizationWorkflowID"));
            ebinding.add((TextBox)e.Item.FindControl("AuthorizationWorkflowCode"));
            ebinding.add((TextBox)e.Item.FindControl("AuthorizationWorkflowDesc"));
            ebinding.init(Request, Session);


            EAuthorizationWorkFlow obj = new EAuthorizationWorkFlow();
            db.toObject(((DataRowView)e.Item.DataItem).Row, obj);
            Hashtable values = new Hashtable();
            db.populate(obj, values);
            ebinding.toControl(values);
        }
        else
        {
            //e.Item.FindControl("Edit").Visible = IsAllowEdit;
            HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("AuthorizationWorkFlowID");
            h.Value = ((DataRowView)e.Item.DataItem)["AuthorizationWorkFlowID"].ToString();
        }
        HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);
    }
    protected void Save_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        EAuthorizationWorkFlow obj = new EAuthorizationWorkFlow();
        Hashtable values           = new Hashtable();


        binding.toValues(values);
        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }

        db.parse(values, obj);
        if (!AppUtils.checkDuplicate(dbConn, db, obj, errors, "AuthorizationWorkFlowCode"))
        {
            return;
        }

        WebUtils.StartFunction(Session, FUNCTION_CODE);
        if (CurID < 0)
        {
            db.insert(dbConn, obj);
            CurID = obj.AuthorizationWorkFlowID;
        }
        else
        {
            db.update(dbConn, obj);
        }
        DBFilter previousDetailFilter = new DBFilter();

        previousDetailFilter.add(new Match("AuthorizationWorkFlowID", obj.AuthorizationWorkFlowID));
        ArrayList previousDetailList = EAuthorizationWorkFlowDetail.db.select(dbConn, previousDetailFilter);

        foreach (EAuthorizationWorkFlowDetail previousDetail in previousDetailList)
        {
            EAuthorizationWorkFlowDetail.db.delete(dbConn, previousDetail);
        }

        foreach (DataRow row in AuthorizationWorkFlowDetailDataTable.Rows)
        {
            EAuthorizationWorkFlowDetail detail = new EAuthorizationWorkFlowDetail();
            detail.AuthorizationGroupID       = (int)row["AuthorizationGroupID"];
            detail.AuthorizationWorkFlowIndex = (int)row["AuthorizationWorkFlowIndex"];
            detail.AuthorizationWorkFlowID    = obj.AuthorizationWorkFlowID;
            EAuthorizationWorkFlowDetail.db.insert(dbConn, detail);
        }
        WebUtils.EndFunction(dbConn);

        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/ESS_AuthorizationWorkFlow_View.aspx?AuthorizationWorkFlowID=" + CurID);
    }
Esempio n. 3
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        EAuthorizationWorkFlow obj = new EAuthorizationWorkFlow();

        obj.AuthorizationWorkFlowID = CurID;
        if (db.select(dbConn, obj))
        {
            DBFilter empPosFilter            = new DBFilter();
            OR       orAuthorizationWorkFlow = new OR();
            orAuthorizationWorkFlow.add(new Match("AuthorizationWorkFlowIDLeaveApp", obj.AuthorizationWorkFlowID));
            orAuthorizationWorkFlow.add(new Match("AuthorizationWorkFlowIDEmpInfoModified", obj.AuthorizationWorkFlowID));
            empPosFilter.add(orAuthorizationWorkFlow);
            empPosFilter.add("empid", true);
            ArrayList empPosList = EEmpPositionInfo.db.select(dbConn, empPosFilter);
            if (empPosList.Count > 0)
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_CODE_USED_BY_EMPLOYEE, new string[] { HROne.Common.WebUtility.GetLocalizedString("Authorization Workflow"), obj.AuthorizationWorkFlowCode }));
                foreach (EEmpPositionInfo empPos in empPosList)
                {
                    EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                    empInfo.EmpID = empPos.EmpID;
                    if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                    {
                        errors.addError("- " + empInfo.EmpNo + ", " + empInfo.EmpEngFullName);
                    }
                    else
                    {
                        EEmpPositionInfo.db.delete(dbConn, empPos);
                    }
                }
                errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT);
                return;
            }
            else
            {
                DBFilter authorizationWorkFlowDetailFilter = new DBFilter();
                authorizationWorkFlowDetailFilter.add(new Match("AuthorizationWorkFlowID", CurID));
                EAuthorizationWorkFlowDetail.db.delete(dbConn, authorizationWorkFlowDetailFilter);

                WebUtils.StartFunction(Session, FUNCTION_CODE);
                db.delete(dbConn, obj);
                WebUtils.EndFunction(dbConn);
            }
        }
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/ESS_AuthorizationWorkFlow_List.aspx");
    }
Esempio n. 4
0
    protected bool loadObject()
    {
        EAuthorizationWorkFlow obj = new EAuthorizationWorkFlow();
        bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        if (!db.select(dbConn, obj))
        {
            return(false);
        }

        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);
        return(true);
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        ArrayList list = new ArrayList();

        foreach (DataListItem item in Repeater.Items)
        {
            CheckBox        c = (CheckBox)item.FindControl("DeleteItem");
            HtmlInputHidden h = (HtmlInputHidden)item.FindControl("AuthorizationWorkFlowID");
            if (c.Checked)
            {
                EAuthorizationWorkFlow obj = new EAuthorizationWorkFlow();
                obj.AuthorizationWorkFlowID = Int32.Parse(h.Value);
                list.Add(obj);
            }
        }
        foreach (EAuthorizationWorkFlow obj in list)
        {
            db.select(dbConn, obj);
            DBFilter empPosFilter            = new DBFilter();
            OR       orAuthorizationWorkFlow = new OR();
            orAuthorizationWorkFlow.add(new Match("AuthorizationWorkFlowIDLeaveApp", obj.AuthorizationWorkFlowID));
            orAuthorizationWorkFlow.add(new Match("AuthorizationWorkFlowIDEmpInfoModified", obj.AuthorizationWorkFlowID));
            empPosFilter.add(orAuthorizationWorkFlow);
            empPosFilter.add("empid", true);
            ArrayList empPosList = EEmpPositionInfo.db.select(dbConn, empPosFilter);
            if (empPosList.Count > 0)
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_CODE_USED_BY_EMPLOYEE, new string[] { HROne.Common.WebUtility.GetLocalizedString("Authorization Workflow"), obj.AuthorizationWorkFlowCode }));
                foreach (EEmpPositionInfo empPos in empPosList)
                {
                    EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                    empInfo.EmpID = empPos.EmpID;
                    if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                    {
                        errors.addError("- " + empInfo.EmpNo + ", " + empInfo.EmpEngFullName);
                    }
                    else
                    {
                        EEmpPositionInfo.db.delete(dbConn, empPos);
                    }
                }
                errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT);
                return;
            }
            else
            {
                DBFilter authorizationWorkFlowDetailFilter = new DBFilter();
                authorizationWorkFlowDetailFilter.add(new Match("AuthorizationWorkFlowID", obj.AuthorizationWorkFlowID));
                EAuthorizationWorkFlowDetail.db.delete(dbConn, authorizationWorkFlowDetailFilter);

                WebUtils.StartFunction(Session, FUNCTION_CODE);
                db.delete(dbConn, obj);
                WebUtils.EndFunction(dbConn);
            }
        }
        view = loadData(info, db, Repeater);
    }
Esempio n. 6
0
        public override CrystalDecisions.CrystalReports.Engine.ReportDocument GenerateReport()
        {
            if (EmpIDList.Count > 0)
            {
                DataSet ds = new DataSet();
                ds.ReadXmlSchema(schemaXSDPath);
                DataTable empInfoTable          = ds.Tables["EmpInfo"];
                DataTable attendanceRecordTable = ds.Tables["AttendanceRecord"];

                DateTime periodFrom = new DateTime(year, month, 1);
                DateTime periodTo   = new DateTime(year, month, DateTime.DaysInMonth(year, month));

                foreach (int EmpID in EmpIDList)
                {
                    EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                    empInfo.EmpID = EmpID;
                    if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                    {
                        DataRow empRow = empInfoTable.NewRow();
                        empRow["EmpID"]      = EmpID;
                        empRow["EmpNo"]      = empInfo.EmpNo;
                        empRow["EmpName"]    = empInfo.EmpEngFullName;
                        empRow["PeriodFrom"] = periodFrom;
                        empRow["PeriodTo"]   = periodTo;

                        EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, periodTo, EmpID);
                        if (empPos != null)
                        {
                            EAuthorizationWorkFlow workFlow = new EAuthorizationWorkFlow();
                            workFlow.AuthorizationWorkFlowID = empPos.AuthorizationWorkFlowIDLeaveApp;
                            if (EAuthorizationWorkFlow.db.select(dbConn, workFlow))
                            {
                                empRow["Section"] = workFlow.AuthorizationWorkFlowDescription;
                            }

                            EWorkHourPattern workHourPattern = new EWorkHourPattern();
                            workHourPattern.WorkHourPatternID = empPos.WorkHourPatternID;
                            if (EWorkHourPattern.db.select(dbConn, workHourPattern))
                            {
                                empRow["RosterGroup"] = workHourPattern.WorkHourPatternCode + " - " + workHourPattern.WorkHourPatternDesc;
                            }
                        }
                        empInfoTable.Rows.Add(empRow);
                    }

                    DBFilter attendanceRecordFilter = new DBFilter();
                    attendanceRecordFilter.add(new Match("EmpID", EmpID));
                    attendanceRecordFilter.add(new Match("AttendanceRecordDate", ">=", periodFrom));
                    attendanceRecordFilter.add(new Match("AttendanceRecordDate", "<=", periodTo));
                    attendanceRecordFilter.add("AttendanceRecordDate", true);
                    ArrayList attendanceRecordList = EAttendanceRecord.db.select(dbConn, attendanceRecordFilter);

                    foreach (EAttendanceRecord attendanceRecord in attendanceRecordList)
                    {
                        DataRow attendanceRecordRow = attendanceRecordTable.NewRow();


                        attendanceRecordRow["AttendanceRecordID"] = attendanceRecord.AttendanceRecordID;
                        attendanceRecordRow["EmpID"] = attendanceRecord.EmpID;
                        attendanceRecordRow["AttendanceRecordDate"] = attendanceRecord.AttendanceRecordDate;
                        if (attendanceRecord.AttendanceRecordWorkStart.Ticks > 0)
                        {
                            attendanceRecordRow["AttendanceRecordWorkStart"] = attendanceRecord.AttendanceRecordWorkStart;
                        }
                        if (attendanceRecord.AttendanceRecordWorkEnd.Ticks > 0)
                        {
                            attendanceRecordRow["AttendanceRecordWorkEnd"] = attendanceRecord.AttendanceRecordWorkEnd;
                        }
                        attendanceRecordRow["AttendanceRecordLateMins"]       = attendanceRecord.AttendanceRecordActualLateMins;
                        attendanceRecordRow["AttendanceRecordEarlyLeaveMins"] = attendanceRecord.AttendanceRecordActualEarlyLeaveMins;
                        if (attendanceRecord.AttendanceRecordIsAbsent && string.IsNullOrEmpty(attendanceRecord.AttendanceRecordRemark))
                        {
                            attendanceRecordRow["AttendanceRecordRemark"] = "Absent";
                        }
                        else
                        {
                            attendanceRecordRow["AttendanceRecordRemark"] = attendanceRecord.AttendanceRecordRemark;
                        }
                        attendanceRecordRow["IsPublicHoliday"] = EPublicHoliday.IsHoliday(dbConn, attendanceRecord.AttendanceRecordDate) || attendanceRecord.AttendanceRecordDate.DayOfWeek == DayOfWeek.Sunday;
                        // Start 0000058, KuangWei, 2014-07-10
                        attendanceRecordRow["AttendanceRecordOvertimeMins"] = attendanceRecord.AttendanceRecordActualOvertimeMins;
                        // End 0000058, KuangWei, 2014-07-10
                        attendanceRecordTable.Rows.Add(attendanceRecordRow);
                    }
                }

                //System.Data.DataTable table = null;
                //foreach (int EmpID in EmpList)
                //{
                //    string select = "P.*,EmpPos.*,Pos.*,Comp.* ";
                //    string from = "from EmpPersonalInfo P LEFT JOIN EmpPositionInfo EmpPos ON P.EmpID=EmpPos.EmpID AND EmpPos.EmpPosEffTo IS NULL LEFT JOIN Position Pos ON EmpPos.PositionID=Pos.PositionID LEFT JOIN Company Comp ON EmpPos.CompanyID=Comp.CompanyID";
                //    DBFilter filter = new DBFilter();
                //    OR or = new OR();
                //    filter.add(new Match("P.EmpID", EmpID));
                //    System.Data.DataTable resulttable = filter.loadData(null, select, from);
                //    if (table == null)
                //        table = resulttable;
                //    else
                //        table.Merge(resulttable);
                //}
                //DBAESEncryptStringFieldAttribute.decode(table, "EmpHKID", true);
                //DBAESEncryptStringFieldAttribute.decode(table, "EmpPassportNo", false);


                //if (reportDocument == null)
                //{
                //    reportDocument = new ReportTemplate.Report_Employee_List();
                //}
                //else
                //{

                //}
                reportDocument.SetDataSource(ds);

                return(reportDocument);
            }
            else
            {
                return(null);
            }
        }