Example #1
0
 public int GetDaysPerMonthByEmployeeFormullaID(int employeePayrollFormulaID, int month, int year)
 {
     try
     {
         DataSet ds = dal.GetAllObject();
         List <HRTimesheetConfigsInfo> list = (List <HRTimesheetConfigsInfo>)GetListFromDataSet(ds);
         HRTimesheetConfigsInfo        objTimesheetConfigsInfo = list.Where(p => p.FK_HREmployeePayrollFormulaID == employeePayrollFormulaID &&
                                                                            p.HRTimesheetConfigYear.Year == year).FirstOrDefault();
         string[] str = new string[] { "HRTimesheetConfigJan", "HRTimesheetConfigFeb", "HRTimesheetConfigMar",
                                       "HRTimesheetConfigApr", "HRTimesheetConfigMay", "HRTimesheetConfigJun", "HRTimesheetConfigJul", "HRTimesheetConfigAug",
                                       "HRTimesheetConfigSep", "HRTimesheetConfigOct", "HRTimesheetConfigNov", "HRTimesheetConfigDec" };
         if (objTimesheetConfigsInfo != null)
         {
             BusinessObject obj  = (BusinessObject)objTimesheetConfigsInfo;
             VinaDbUtil     util = new VinaDbUtil();
             object         o    = util.GetPropertyValue(objTimesheetConfigsInfo, str[month - 1]);
             return(int.Parse(o.ToString()));
         }
         return(0);
     }
     catch (Exception)
     {
         return(0);
     }
 }
Example #2
0
        public static void RoundByCurrency(BusinessObject obj, int currencyID)
        {
            VinaDbUtil dbUtil = new VinaDbUtil();

            GECurrenciesController currencyController = new GECurrenciesController();
            GECurrenciesInfo       currency           = currencyController.GetObjectByID(currencyID) as GECurrenciesInfo;
        }
Example #3
0
 public bool IsValidForeignKeyProperty(String strForeignKeyColumn)
 {
     try
     {
         VinaDbUtil dbUtil = new VinaDbUtil();
         //String strMainObjectTableName = MainObject.GetType().Name.Substring(0, MainObject.GetType().Name.Length - 4);
         String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
         String strPrimaryTable        = ((IBaseModuleERP)Module).GetTreePrimaryTableWhichForeignColumnReferenceTo(strMainObjectTableName, strForeignKeyColumn);
         String strPrimaryColumn       = ((IBaseModuleERP)Module).GetTreePrimaryTableWhichForeignColumnReferenceTo(strMainObjectTableName, strForeignKeyColumn);
         BaseBusinessController objPrimaryTableObjectController = BusinessControllerFactory.GetBusinessController(strPrimaryTable + "Controller");
         int iForeignKeyColumnValue = Convert.ToInt32(dbUtil.GetPropertyValue(MainObject, strForeignKeyColumn));
         if (iForeignKeyColumnValue > 0)
         {
             return(objPrimaryTableObjectController.IsExist(iForeignKeyColumnValue));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #4
0
        public void InitVinaList(ERPModuleEntities ent, String strParentTableName, String strItemTableName, String strRelation)
        {
            Entity = ent;
            VinaDbUtil dbUtil = new VinaDbUtil();

            ParentTableName = strParentTableName;
            ItemTableName   = strItemTableName;
            Relation        = strRelation;
            switch (strRelation)
            {
            case cstRelationForeign:
            {
                String strParentTablePrimaryColumn = dbUtil.GetTablePrimaryColumn(ParentTableName);
                String strItemTablePrimaryColumn   = dbUtil.GetTablePrimaryColumn(ItemTableName);
                ItemTableForeignKey = "FK_" + strParentTablePrimaryColumn;
                break;
            }

            case cstRelationParent:
            {
                ItemTableForeignKey = ItemTableName.Substring(0, ItemTableName.Length - 1) + "ParentID";
                break;
            }
            }
        }
Example #5
0
        public void AddDefaulArrangementShiftEntries(HREmployeeArrangementShiftsInfo objEmployeeArrangementShiftsInfo, HREmployeesInfo objEmployeesInfo)
        {
            objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.Clear();

            ArrangementShiftEntities   entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo    objArrangementShiftsInfo   = (HRArrangementShiftsInfo)entity.MainObject;
            ADWorkingShiftsController  objWorkingShiftsController = new ADWorkingShiftsController();
            List <ADWorkingShiftsInfo> workingShifts = entity.WorkingShifts;
            ADWorkingShiftsInfo        defaultParam  = (ADWorkingShiftsInfo)workingShifts.Where(o => o.ADWorkingShiftID == objEmployeesInfo.FK_ADWorkingShiftID).FirstOrDefault();

            if (defaultParam != null)
            {
                VinaDbUtil dbUtil  = new VinaDbUtil();
                int        numDays = NumOfDayInMonth();
                for (int i = 1; i <= numDays; i++)
                {
                    DateTime currentDate = objArrangementShiftsInfo.HRArrangementShiftFromDate.Date.AddDays(i - 1);
                    HRArrangementShiftEntrysInfo entry = new HRArrangementShiftEntrysInfo();
                    entry.FK_HREmployeeID                 = objEmployeeArrangementShiftsInfo.FK_HREmployeeID;
                    entry.FK_HRArrangementShiftID         = objEmployeeArrangementShiftsInfo.FK_HRArrangementShiftID;
                    entry.FK_HREmployeeArrangementShiftID = objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftID;
                    entry.HRArrangementShiftEntryDate     = currentDate;
                    entry.FK_ADWorkingShiftID             = defaultParam.ADWorkingShiftID;

                    //String propertyName = String.Format("{0}{1}", "HREmployeeArrangementShiftDate", i);
                    objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.Add(entry);
                }
            }
        }
Example #6
0
        public virtual void Invalidate(int iObjectID)
        {
            //Invalidate lookup edit columns to reflect all changes of lookup table
            //if (GridControl != null)
            //    GridControl.InvalidateLookupEditColumns();

            VinaDbUtil             dbUtil            = new VinaDbUtil();
            BaseBusinessController objItemController = BusinessControllerFactory.GetBusinessController(ItemTableName + "Controller");
            DataSet ds = new DataSet();

            if (Relation.Equals(cstRelationForeign))
            {
                ds = objItemController.GetAllDataByForeignColumn(ItemTableForeignKey, iObjectID);
            }
            else if (Relation.Equals(cstRelationParent))
            {
                ds = objItemController.GetAllObjectsByObjectParentID(iObjectID);
            }
            else if (Relation.Equals(cstRelationNone))
            {
                ds = objItemController.GetAllObjects();
            }
            DataView view = ds.Tables[0].DefaultView;
            string   ID   = ItemTableName.Substring(0, ItemTableName.Length - 1) + "ID";

            view.Sort = ID + " ASC";
            DataTable sortIDData = view.ToTable();

            ds.Clear();
            ds.Merge(sortIDData);
            Invalidate(ds);
        }
Example #7
0
        protected virtual bool IsValidObjectNo(string objectNo)
        {
            VinaDbUtil             dbUtil = new VinaDbUtil();
            BaseBusinessController objCurrentObjectController = BusinessControllerFactory.GetBusinessController(CurrentModuleEntity.MainObject.GetType().Name.Substring(0, CurrentModuleEntity.MainObject.GetType().Name.Length - 4) + "Controller");
            String mainTable = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
            String mainTablePrimaryColumn = dbUtil.GetTablePrimaryColumn(mainTable);
            bool   isValid = true;

            if (!String.IsNullOrEmpty(objectNo))
            {
                if (this.Toolbar.ModuleAction == BaseToolbar.ModuleNew)
                {
                    if (objCurrentObjectController.IsExist(objectNo))
                    {
                        MessageBox.Show("Mã đã tồn tại trong hệ thống vui lòng nhập mã khác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        isValid = false;
                    }
                }
                else if (this.Toolbar.ModuleAction == BaseToolbar.ModuleEdit)
                {
                    BusinessObject objMainObject = (BusinessObject)objCurrentObjectController.GetObjectByNo(objectNo);
                    if (objMainObject != null)
                    {
                        int iMainObjectID = Convert.ToInt32(dbUtil.GetPropertyValue(objMainObject, mainTablePrimaryColumn));
                        if (iMainObjectID != Toolbar.CurrentObjectID)
                        {
                            MessageBox.Show("Mã đã tồn tại trong hệ thống vui lòng nhập mã khác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            isValid = false;
                        }
                    }
                }
            }
            return(isValid);
        }
Example #8
0
 public virtual BusinessObject GetBusinessObject(int pRowHandle, params string[] pProperties)
 {
     if (pRowHandle < 0)
     {
         return(null);
     }
     if (string.IsNullOrWhiteSpace(VinaDataSource))
     {
         VinaDbUtil     vinaDbUtil = new VinaDbUtil();
         BusinessObject obj        = BusinessObjectFactory.GetBusinessObject(VinaDataSource + "Info");
         if (obj != null)
         {
             System.Threading.Tasks.Parallel.For(0, pProperties.Length, i =>
             {
                 object objProp = (MainView as DevExpress.XtraGrid.Views.Grid.GridView).GetRowCellValue(pRowHandle, pProperties[i]);
                 if (objProp != DBNull.Value)
                 {
                     vinaDbUtil.SetPropertyValue(obj, pProperties[i], objProp);
                 }
             });
         }
         return(obj);
     }
     return((BusinessObject)(MainView as DevExpress.XtraGrid.Views.Grid.GridView).GetRow(pRowHandle));
 }
Example #9
0
        public virtual int Save()
        {
            int  iObjectID  = 0;
            bool isContinue = true;

            VinaDbUtil dbUtil       = new VinaDbUtil();
            String     strMainTable = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);

            String strMainTablePrimaryColumn = strMainTable.Substring(0, strMainTable.Length - 1) + "ID";
            String strMainTableNoColumn      = strMainTablePrimaryColumn.Substring(0, strMainTablePrimaryColumn.Length - 2) + "No";
            String strObjectNo = dbUtil.GetPropertyStringValue(CurrentModuleEntity.MainObject, strMainTableNoColumn);

            isContinue = IsValidObjectNo(strObjectNo);
            if (isContinue)
            {
                iObjectID = CurrentModuleEntity.SaveMainObject();

                if (iObjectID > 0)
                {
                    CurrentModuleEntity.SaveModuleObjects();
                }
                return(iObjectID);
            }
            else
            {
                return(0);
            }
        }
Example #10
0
        public virtual void ActionInvalidate(int objectID)
        {
            VinaDbUtil dbUtil     = new VinaDbUtil();
            string     tableName  = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
            string     primaryKey = dbUtil.GetTablePrimaryColumn(tableName);

            if (Toolbar.ObjectCollection != null)
            {
                for (int i = 0; i < Toolbar.ObjectCollection.Tables[0].Rows.Count; i++)
                {
                    if (objectID == Convert.ToInt32(Toolbar.ObjectCollection.Tables[0].Rows[i][primaryKey]))
                    {
                        Toolbar.CurrentIndex = i;
                        //FocusRowOfGridSearchResultByToolbarCurrentIndex();
                        return;
                    }
                }
            }

            //If can't find the object in toolbar's collection
            BaseBusinessController controller = BusinessControllerFactory.GetBusinessController(tableName + "Controller");

            if (controller != null)
            {
                DataSet ds = controller.GetDataSetByID(objectID);
                Toolbar.SetToolbar(ds);
                //InvalidateAfterSearch(null, String.Empty);
            }
        }
Example #11
0
        protected void InitObjectDataFromLookupTable(DataTable dataSource, string tableName)
        {
            VinaDbUtil vinaDbUtil = new VinaDbUtil();
            DataTable  dataTable  = dataSource.Copy();
            bool       flag1      = false;

            if (this.VinaAllowDummy && dataTable.Rows.Count > 0)
            {
                object obj = dataTable.Rows[0][this.Properties.ValueMember];
                if (obj is int)
                {
                    if (Convert.ToInt32(obj) > 0)
                    {
                        DataRow row = dataTable.NewRow();
                        row[this.Properties.ValueMember] = (object)0;
                        dataTable.Rows.InsertAt(row, 0);
                        flag1 = true;
                    }
                }
                else if (obj is string && !string.IsNullOrEmpty(obj.ToString()))
                {
                    DataRow row = dataTable.NewRow();
                    row[this.Properties.ValueMember] = (object)string.Empty;
                    dataTable.Rows.InsertAt(row, 0);
                    flag1 = true;
                }
            }
            this.Properties.DataSource = (object)dataTable;
            if (dataTable.Rows.Count <= 0)
            {
                return;
            }
            this.ItemIndex = 0;
        }
Example #12
0
        protected void InitLookupEditColumns()
        {
            VinaDbUtil vinaDbUtil  = new VinaDbUtil();
            string     lookuptable = vinaDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(this.VinaDataSource, this.VinaDataMember);

            GELookupColumnsController  objLookupColumnsController = new GELookupColumnsController();
            List <GELookupColumnsInfo> lookupColumns = objLookupColumnsController.GetLookupColumnByLookupTableName(lookuptable);

            if (lookupColumns.Count() == 0)
            {
                return;
            }

            this.Properties.Columns.Clear();
            this.Properties.BestFitMode = BestFitMode.None;
            LookUpColumnInfo column = new LookUpColumnInfo();

            lookupColumns.ForEach(o =>
            {
                column              = new LookUpColumnInfo();
                column.Caption      = o.GELookupColumnCaption;
                column.FieldName    = o.GELookupColumnFieldName;
                column.FormatType   = string.IsNullOrWhiteSpace(o.GELookupColumnFormatType) ? FormatType.None : (FormatType)Enum.Parse(typeof(FormatType), o.GELookupColumnFormatType);
                column.FormatString = o.GELookupColumnFormatString;
                column.Width        = o.GELookupColumnWidth;
                this.Properties.Columns.Add(column);
                this.Properties.PopupWidth += column.Width;
            });
        }
Example #13
0
        public void UpdateTotalLeaveDays(HRLeaveDaysInfo leaveDay)
        {
            HRLeaveDaysController objLeaveDaysController = new HRLeaveDaysController();
            HREmployeesController objEmployeesController = new HREmployeesController();
            HREmployeesInfo       obj = (HREmployeesInfo)objEmployeesController.GetObjectByID(leaveDay.FK_HREmployeeID);
            double leaveDays          = 0;

            if (obj != null)
            {
                List <HRLeaveDaysInfo> LeaveDaysList = new List <HRLeaveDaysInfo>();
                LeaveDaysList = objLeaveDaysController.GetLeaveDayOnYearByHREmployeeID(leaveDay.FK_HREmployeeID);
                foreach (HRLeaveDaysInfo item in LeaveDaysList)
                {
                    if (item.HRTimeSheetParamNo == "Pn")
                    {
                        leaveDays = leaveDays + 1;
                    }
                    else if (item.HRTimeSheetParamNo == "Pn 1/2")
                    {
                        leaveDays = leaveDays + 0.5;
                    }
                }
            }
            VinaDbUtil       dbUtil = new VinaDbUtil();
            LeaveDayEntities entity = (LeaveDayEntities)CurrentModuleEntity;

            leaveDay.TotalLeaveDays = 0;

            for (int i = 1; i <= 31; i++)
            {
                string paramNo = dbUtil.GetPropertyStringValue(leaveDay, string.Format("HRLeaveDayDate{0}", i));
                if (!string.IsNullOrEmpty(paramNo))
                {
                    if (paramNo.IndexOf("1/2") > 0)
                    {
                        leaveDay.TotalLeaveDays = leaveDay.TotalLeaveDays + decimal.Parse("0.5");
                    }
                    else
                    {
                        leaveDay.TotalLeaveDays = leaveDay.TotalLeaveDays + 1;
                    }
                }
            }

            //if ((leaveDays + leaveDay.TotalLeaveDays) >= 12)
            //{
            //    MessageBox.Show("Số ngày nghỉ phép không còn!",
            //                CommonLocalizedResources.MessageBoxDefaultCaption,
            //                MessageBoxButtons.OK,
            //                MessageBoxIcon.Information);
            //    leaveDay = (HRLeaveDaysInfo)leaveDay.OldObject;
            //    entity.LeaveDaysList.GridControl.RefreshDataSource();
            //}
            //else
            //{
            //    entity.LeaveDaysList.GridControl.RefreshDataSource();
            //}
            entity.LeaveDaysList.GridControl.RefreshDataSource();
        }
Example #14
0
        public void SetEmployeeArrangementShiftValue(HREmployeeArrangementShiftsInfo objEmployeeArrangementShiftsInfo)
        {
            HRArrangementShiftsInfo arrangementShift = (HRArrangementShiftsInfo)MainObject;
            List <string>           employeeArrangementShiftValueList = new List <string> {
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty
            };

            foreach (HRArrangementShiftEntrysInfo arrangementShiftEntry in objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList)
            {
                if (arrangementShiftEntry.HRArrangementShiftEntryDate.Date >= arrangementShift.HRArrangementShiftFromDate.Date &&
                    arrangementShiftEntry.HRArrangementShiftEntryDate.Date <= arrangementShift.HRArrangementShiftToDate.Date)
                {
                    int index = (int)(arrangementShiftEntry.HRArrangementShiftEntryDate.Date - arrangementShift.HRArrangementShiftFromDate.Date).TotalDays + 1;
                    if (index > 31)
                    {
                        MessageBox.Show("Bạn không thể chọn thời gian xếp ca quá 31 ngày!", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    string workingShifId = string.Empty;
                    ADWorkingShiftsInfo objWorkingShiftsInfo = WorkingShifts.Where(o => o.ADWorkingShiftID == arrangementShiftEntry.FK_ADWorkingShiftID).FirstOrDefault();
                    if (objWorkingShiftsInfo != null)
                    {
                        workingShifId = objWorkingShiftsInfo.ADWorkingShiftName;
                    }
                    if (!string.IsNullOrEmpty(workingShifId))
                    {
                        if (string.IsNullOrEmpty(employeeArrangementShiftValueList[index - 1].Trim()))
                        {
                            employeeArrangementShiftValueList[index - 1] = workingShifId;
                        }
                        else
                        {
                            employeeArrangementShiftValueList[index - 1] += String.Format(", {0}", workingShifId);
                        }
                    }
                }
            }

            VinaDbUtil dbUtil  = new VinaDbUtil();
            int        numDays = ((ArrangementShiftModule)Module).NumOfDayInMonth();

            if (numDays > 31)
            {
                numDays = 31;
            }
            for (int i = 1; i <= numDays; i++)
            {
                String propertyName = String.Format("{0}{1}", "HREmployeeArrangementShiftDate", i.ToString());
                dbUtil.SetPropertyValue(objEmployeeArrangementShiftsInfo, propertyName, employeeArrangementShiftValueList[i - 1]);
            }
        }
Example #15
0
        public virtual int CreateMainObject()
        {
            VinaDbUtil dbUtil       = new VinaDbUtil();
            int        iObjectID    = 0;
            bool       editObjectNo = true;

            //Get Table which Business object Represent
            String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
            BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(strMainObjectTableName + "Controller");

            //Set Object No value
            String strPrimaryColumn = strMainObjectTableName.Substring(0, strMainObjectTableName.Length - 1) + "ID";
            String strColumnNo      = strMainObjectTableName.Substring(0, strMainObjectTableName.Length - 1) + "No";
            String strMainObjectNo  = dbUtil.GetPropertyStringValue(MainObject, strColumnNo);
            int    numberingStart   = 0;

            try
            {
                if (strMainObjectNo.Equals(NewObjectNoText))
                {
                    editObjectNo    = false;
                    strMainObjectNo = GetMainObjectNo(ref numberingStart);
                    dbUtil.SetPropertyValue(MainObject, strColumnNo, strMainObjectNo);
                }

                //Set Created User, Created Date
                dbUtil.SetPropertyValue(MainObject, AACreatedUser, VinaApp.CurrentUserName);
                dbUtil.SetPropertyValue(MainObject, AACreatedDate, DateTime.Now);


                iObjectID = dbUtil.GetPropertyIntValue(MainObject, strPrimaryColumn);
                if (iObjectID == 0)
                {
                    iObjectID = objMainObjectController.CreateObject(MainObject);
                }
                else
                {
                    objMainObjectController.CreateObject(MainObject, iObjectID);
                }
            }
            catch (Exception ex)
            {
                if (!editObjectNo)
                {
                    dbUtil.SetPropertyValue(MainObject, strColumnNo, NewObjectNoText);
                    dbUtil.SetPropertyValue(MainObject, strPrimaryColumn, 0);
                }

                iObjectID = 0;
                MessageBox.Show(ex.Message.ToString());
            }

            return(iObjectID);
        }
Example #16
0
        public virtual void CreateMainObjectRule()
        {
            VinaDbUtil dbUtil = new VinaDbUtil();

            MainObject.BusinessRuleCollections = new List <BusinessRule>();
            String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);

            DataSet dsColumns = dbUtil.GetNotAllowNullTableColumns(strMainObjectTableName);

            if (dsColumns.Tables.Count > 0)
            {
                AAColumnAliasController  objColumnAlliasController = new AAColumnAliasController();
                List <AAColumnAliasInfo> LstColumnAlias            = objColumnAlliasController.GetColumnAliasByTableName(strMainObjectTableName);
                foreach (DataRow rowColumn in dsColumns.Tables[0].Rows)
                {
                    String strColumnName            = rowColumn["COLUMN_NAME"].ToString();
                    String strBrokenRuleDescription = String.Empty;
                    //Add rule if column is not primary key
                    if (!dbUtil.IsPrimaryKey(strMainObjectTableName, strColumnName))
                    {
                        //If column does not allow null
                        if (!dbUtil.ColumnIsAllowNull(strMainObjectTableName, strColumnName))
                        {
                            AAColumnAliasInfo objColumnAliasInfo = LstColumnAlias.Where(a => a.AATableName == strMainObjectTableName &&
                                                                                        a.AAColumnAliasName == strColumnName).FirstOrDefault();
                            if (objColumnAliasInfo != null)
                            {
                                strBrokenRuleDescription = String.Format(string.Format("{0} không thể để trống", objColumnAliasInfo.AAColumnAliasCaption));
                            }
                            else
                            {
                                strBrokenRuleDescription = String.Format(string.Format("{0} không thể để trống", strColumnName));
                            }

                            if (((IBaseModuleERP)Module).IsForeignKey(strMainObjectTableName, strColumnName))
                            {
                                BusinessRule foreignKeyRule = new BusinessRule(
                                    strColumnName,
                                    strBrokenRuleDescription,
                                    IsValidForeignKeyProperty);
                                MainObject.BusinessRuleCollections.Add(foreignKeyRule);
                            }
                            else
                            {
                                BusinessRule nonForeignKeyRule = new BusinessRule(strColumnName, strBrokenRuleDescription, IsValidNonForeignKeyPropety);
                                MainObject.BusinessRuleCollections.Add(nonForeignKeyRule);
                            }
                        }
                    }
                }
            }
            dsColumns.Dispose();
        }
Example #17
0
        public void SetEmployeeTimeSheetValue(HREmployeeTimeSheetsInfo objEmployeeTimeSheetsInfo)
        {
            HRTimeSheetsInfo timeSheet = (HRTimeSheetsInfo)MainObject;
            List <string>    employeeTimeSheetValueList = new List <string> {
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty
            };

            foreach (HRTimeSheetEntrysInfo timeSheetEntry in objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList)
            {
                if (timeSheetEntry.HRTimeSheetEntryDate.Date >= timeSheet.HRTimeSheetFromDate.Date &&
                    timeSheetEntry.HRTimeSheetEntryDate.Date <= timeSheet.HRTimeSheetToDate.Date)
                {
                    int    index            = (int)(timeSheetEntry.HRTimeSheetEntryDate.Date - timeSheet.HRTimeSheetFromDate.Date).TotalDays + 1;
                    string timeSheetParamNo = string.Empty;
                    HRTimeSheetParamsInfo objTimeSheetParamsInfo = TimeSheetParams.Where(t => t.HRTimeSheetParamID == timeSheetEntry.FK_HRTimeSheetParamID).FirstOrDefault();
                    if (objTimeSheetParamsInfo != null)
                    {
                        timeSheetParamNo = objTimeSheetParamsInfo.HRTimeSheetParamNo;
                    }
                    if (!string.IsNullOrEmpty(timeSheetParamNo))
                    {
                        if (string.IsNullOrEmpty(employeeTimeSheetValueList[index - 1].Trim()))
                        {
                            employeeTimeSheetValueList[index - 1] = timeSheetParamNo;
                        }
                        else
                        {
                            employeeTimeSheetValueList[index - 1] += String.Format(", {0}", timeSheetParamNo);
                        }
                    }
                }
            }

            VinaDbUtil dbUtil  = new VinaDbUtil();
            int        numDays = ((TimeSheetModule)Module).NumOfDayInMonth();

            if (numDays > 31)
            {
                numDays = 31;
            }
            for (int i = 1; i <= numDays; i++)
            {
                String propertyName = String.Format("{0}{1}", "HREmployeeTimeSheetDate", i.ToString());
                dbUtil.SetPropertyValue(objEmployeeTimeSheetsInfo, propertyName, employeeTimeSheetValueList[i - 1]);
            }
        }
Example #18
0
        protected void InvalidateEmployee()
        {
            VinaDbUtil            dbUtil                 = new VinaDbUtil();
            int                   employeeID             = dbUtil.GetPropertyIntValue(CurrentModuleEntity.MainObject, "FK_HREmployeeID");
            HREmployeesController objEmployeesController = new HREmployeesController();
            HREmployeesInfo       objHREmployeesInfo     = (HREmployeesInfo)objEmployeesController.GetObjectByID(employeeID);

            if (objHREmployeesInfo != null)
            {
                dbUtil.SetPropertyValue(CurrentModuleEntity.MainObject, String.Format("{0}EmployeePicture", MainTablePrefix), objHREmployeesInfo.HREmployeePicture);
                CurrentModuleEntity.UpdateMainObjectBindingSource();
            }
        }
Example #19
0
        public void SaveLeaveDays(DateTime dateFrom, DateTime dateTo)
        {
            VinaDbUtil                  dbUtil = new VinaDbUtil();
            LeaveDayEntities            entity = (LeaveDayEntities)CurrentModuleEntity;
            HRTimeSheetParamsController objTimeSheetParamsController = new HRTimeSheetParamsController();

            commonParams = objTimeSheetParamsController.GetTimeSheetParamsByTimeSheetType(TimeSheetParamType.Common.ToString());
            HRLeaveDaysController objLeaveDaysController = new HRLeaveDaysController();

            foreach (HRLeaveDaysInfo employeeLeaveDay in entity.LeaveDaysList)
            {
                //objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, employeeLeaveDay.HRLeaveDayDate);
                for (int i = 1; i <= 31; i++)
                {
                    string[] paramNumbers = dbUtil.GetPropertyStringValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", i)).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (dateFrom.Date.AddDays(i - 1) <= dateTo.Date)
                    {
                        objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, dateFrom.Date.AddDays(i - 1));
                    }
                    for (int j = 0; j < paramNumbers.Length; j++)
                    {
                        string paramNo = paramNumbers[j].Trim();
                        //string paramNo = dbUtil.GetPropertyStringValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", i));
                        if (!string.IsNullOrEmpty(paramNo))
                        {
                            HRTimeSheetParamsInfo param = commonParams.Where(p => p.HRTimeSheetParamNo == paramNo).FirstOrDefault();
                            if (param != null)
                            {
                                HRLeaveDaysInfo leaveDay = new HRLeaveDaysInfo();
                                leaveDay.FK_HREmployeeID       = employeeLeaveDay.FK_HREmployeeID;
                                leaveDay.FK_HRTimeSheetParamID = param.HRTimeSheetParamID;
                                //leaveDay.HRLeaveDayDate = new DateTime(employeeLeaveDay.HRLeaveDayDate.Year, employeeLeaveDay.HRLeaveDayDate.Month, i);
                                leaveDay.HRLeaveDayDate = dateFrom.Date.AddDays(i - 1);
                                //objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, leaveDay.HRLeaveDayDate);
                                objLeaveDaysController.CreateObject(leaveDay);
                            }
                        }
                        //else
                        //{
                        //    objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, dteFrom.DateTime.Date.AddDays(i - 1));
                        //}
                    }
                }
            }

            MessageBox.Show("Lưu thành công",
                            "Thông báo",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Example #20
0
        public virtual int PosOf(String strPropertyName, object objPropertyValue)
        {
            VinaDbUtil dbUtil = new VinaDbUtil();

            for (int i = 0; i < this.Count; i++)
            {
                object objValue = dbUtil.GetPropertyValue((T)this[i], strPropertyName);
                if (objPropertyValue.Equals(objValue))
                {
                    return(i);
                }
            }
            return(-1);
        }
Example #21
0
        public virtual int UpdateMainObject()
        {
            int    iObjectID = 0;
            String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
            BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(strMainObjectTableName + "Controller");

            VinaDbUtil dbUtil = new VinaDbUtil();

            dbUtil.SetPropertyValue(MainObject, AAUpdatedUser, VinaApp.CurrentUserName);
            dbUtil.SetPropertyValue(MainObject, AAUpdatedDate, DateTime.Now);

            iObjectID = objMainObjectController.UpdateObject(MainObject);
            return(iObjectID);
        }
Example #22
0
        protected virtual GridView InitializeGridView()
        {
            GridView view = (GridView)this.ViewCollection[0];

            view.Name = "fld_dgv" + this.Name.Substring(7);
            view.OptionsBehavior.Editable              = true;
            view.OptionsBehavior.AllowAddRows          = DefaultBoolean.True;
            view.OptionsBehavior.Editable              = true;
            view.OptionsBehavior.AutoSelectAllInEditor = false;
            view.OptionsNavigation.AutoFocusNewRow     = true;

            view.OptionsView.ShowGroupPanel                   = false;
            view.OptionsView.ColumnAutoWidth                  = false;
            view.OptionsView.ShowDetailButtons                = false;
            view.OptionsNavigation.EnterMoveNextColumn        = true;
            view.OptionsSelection.EnableAppearanceFocusedCell = true;
            view.OptionsSelection.EnableAppearanceFocusedRow  = false;
            view.OptionsCustomization.AllowFilter             = true;
            view.OptionsNavigation.UseTabKey                  = false;
            view.GridControl = (GridControl)this;

            this.InitGridViewColumns(view);
            VinaDbUtil vinaDbUtil = new VinaDbUtil();

            try
            {
                //view.CustomDrawCell += new RowCellCustomDrawEventHandler(this.GridView_CustomDrawCell);
                view.InitNewRow        += new InitNewRowEventHandler(this.GridView_InitNewRow);
                view.FocusedRowChanged += new FocusedRowChangedEventHandler(this.GridView_FocusedRowChanged);
                //view.Click += new System.EventHandler(this.GridView_Click);
                view.CellValueChanged += new CellValueChangedEventHandler(this.GridView_CellValueChanged);
                view.KeyUp            += new KeyEventHandler(this.GridView_KeyUp);
                //view.ValidateRow += new ValidateRowEventHandler(this.GridView_ValidateRow);
                //view.InvalidRowException += new InvalidRowExceptionEventHandler(this.GridView_InvalidRowException);
                view.ValidatingEditor += new BaseContainerValidateEditorEventHandler(this.GridView_ValidatingEditor);
                view.ShownEditor      += new System.EventHandler(this.GridView_ShownEditor);
                //view.ShowingEditor += new CancelEventHandler(this.gridView_ShowingEditor);
                view.InvalidValueException += new InvalidValueExceptionEventHandler(GridView_InvalidValueException);
            }
            catch (Exception)
            {
            }
            //view.GridMenuItemClick += new GridMenuItemClickEventHandler(this.gridView_GridMenuItemClick);
            //view.ShowGridMenu += new GridMenuEventHandler(this.gridView_ShowGridMenu);
            //view.CustomSummaryExists += new CustomSummaryExistEventHandler(this.gridView_CustomSummaryExists);
            //this.InvalidateLookupEditColumns();
            return(view);
        }
Example #23
0
 public virtual void InvalidateLookupEditColumns()
 {
     foreach (GridColumn column in (CollectionBase)((ColumnView)this.MainView).Columns)
     {
         if (column.ColumnEdit != null && column.ColumnEdit is RepositoryItemLookUpEdit)
         {
             VinaDbUtil bosDbUtil = new VinaDbUtil();
             RepositoryItemLookUpEdit columnEdit = (RepositoryItemLookUpEdit)column.ColumnEdit;
             string columnReferenceTo            = bosDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(this.VinaDataSource, column.FieldName);
             if (!string.IsNullOrEmpty(columnReferenceTo) && this.LookupTables.ContainsKey((object)columnReferenceTo))
             {
                 columnEdit.DataSource = (object)((DataSet)this.LookupTables[(object)columnReferenceTo]).Tables[0];
             }
         }
     }
 }
Example #24
0
        protected virtual void AddColumnsToGridView(string strTableName, GridView gridView)
        {
            VinaDbUtil vinaDbUtil = new VinaDbUtil();
            AAColumnAliasController  objColumnAliasController = new AAColumnAliasController();
            List <AAColumnAliasInfo> columnAlias = objColumnAliasController.GetColumnAliasByTableName(strTableName);

            columnAlias.ForEach(o =>
            {
                if (gridView.Columns.ColumnByFieldName(o.AAColumnAliasName) == null)
                {
                    GridColumn column = this.InitGridColumn(strTableName, -1, o.AAColumnAliasName, o.AAColumnAliasCaption, 50);
                    if (vinaDbUtil.IsForeignKey(strTableName, o.AAColumnAliasName))
                    {
                        RepositoryItemLookUpEdit itemBosLookupEdit = this.InitColumnLookupEdit(strTableName, o.AAColumnAliasName, o.AAColumnAliasCaption);
                        if (itemBosLookupEdit != null)
                        {
                            column.ColumnEdit = (DevExpress.XtraEditors.Repository.RepositoryItem)itemBosLookupEdit;
                        }
                    }
                    else
                    {
                        string empty     = string.Empty;
                        string groupName = o.AAColumnAliasName.Substring(2, o.AAColumnAliasName.Length - 2);
                        if (VinaUtil.ADConfigValueUtility.ContainsKey(groupName))
                        {
                            RepositoryItemLookUpEdit itemLookUpEdit = this.InitRepositoryForConfigValues(VinaUtil.ADConfigValueUtility[groupName]);
                            column.ColumnEdit = itemLookUpEdit;
                        }
                        else
                        {
                            //column.ColumnEdit = this.InitColumnRepositoryFromFieldFormatGroup(strTableName, objectFromDataRow.AAColumnAliasName);
                            //if (column.ColumnEdit != null)
                            //    column.ColumnEdit.MouseWheel += new MouseEventHandler(this.ColumnEdit_MouseWheel);
                        }
                    }
                    column.OptionsColumn.AllowEdit = false;
                    gridView.Columns.Add(column);
                }
                else
                {
                    gridView.Columns[o.AAColumnAliasName].Caption = o.AAColumnAliasCaption;
                }
            });
        }
Example #25
0
        protected virtual bool IsInvalidInput()
        {
            CurrentModuleEntity.CreateMainObjectRule();
            this.ErrorTable = this.InitErrorTable();
            this.CheckExtraInput();
            if (this.CurrentModuleEntity.MainObject != null)
            {
                VinaDbUtil bosDbUtil = new VinaDbUtil();
                this.ErrorTable.Rows.Clear();
                //TODO Check Error From Database
                string dataSource = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
                foreach (BusinessRule r in CurrentModuleEntity.MainObject.BusinessRuleCollections)
                {
                    bool isRuleBroken = !r.ValidateRule(CurrentModuleEntity.MainObject);
                    if (isRuleBroken)
                    {
                        AddErrorToErrorScreen(r.Description, dataSource, r.PropertyName);
                    }
                }
            }
            if (this.ErrorTable.Rows.Count == 0)
            {
                return(false);
            }

            if (this.ErrorMessageScreen == null)
            {
                this.ErrorMessageScreen        = new GuiErrorMessage(this.ErrorTable);
                this.ErrorMessageScreen.Module = (BaseModule)this;
            }
            else if (this.ErrorMessageScreen.IsDisposed)
            {
                this.ErrorMessageScreen        = new GuiErrorMessage(this.ErrorTable);
                this.ErrorMessageScreen.Module = (BaseModule)this;
            }
            //this.ErrorMessageScreen.Show();
            if (ErrorTable.Rows.Count > 0)
            {
                ErrorMessageScreen = new GuiErrorMessage(this.ErrorTable);
                ErrorMessageScreen.ShowDialog();
                return(true);
            }
            return(true);
        }
Example #26
0
 public override void BindingDataControl(Control ctrl)
 {
     try
     {
         VinaDbUtil        dbUtil          = new VinaDbUtil();
         String            strDataSource   = dbUtil.GetPropertyStringValue(ctrl, cstDataSourcePropertyName);
         String            strDataMember   = dbUtil.GetPropertyStringValue(ctrl, cstDataMemberPropertyName);
         String            strPropertyName = dbUtil.GetPropertyStringValue(ctrl, "VinaPropertyName");
         ERPModuleEntities entity          = ((BaseModuleERP)Module).CurrentModuleEntity;
         if (ctrl.Tag != null)
         {
             if (ctrl.Tag.Equals(DataControl))
             {
                 String strMainModuleTable = VinaUtil.GetTableNameFromBusinessObject(entity.MainObject);
                 if (strDataSource.Equals(strMainModuleTable))
                 {
                     if (((BaseModuleERP)Module).CurrentModuleEntity.MainObject != null)
                     {
                         ctrl.DataBindings.Add(
                             new Binding(strPropertyName,
                                         entity.MainObjectBindingSource,
                                         strDataMember,
                                         true,
                                         DataSourceUpdateMode.OnPropertyChanged));
                     }
                 }
             }
             else if (ctrl.Tag.Equals(SearchControl))
             {
                 if (entity.SearchObjectBindingSource != null)
                 {
                     ctrl.DataBindings.Add(new Binding(strPropertyName,
                                                       entity.SearchObjectBindingSource,
                                                       strDataMember,
                                                       true,
                                                       DataSourceUpdateMode.OnPropertyChanged));
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
Example #27
0
        public virtual void SetProductPrice(BusinessObject item)
        {
            VinaDbUtil dbUtil          = new VinaDbUtil();
            String     itemTableName   = VinaUtil.GetTableNameFromBusinessObject(item);
            string     itemTablePrefix = itemTableName.Substring(0, itemTableName.Length - 1);

            //Get Item Qty
            String  columnName = itemTablePrefix + "ProductQty";
            decimal qty        = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            if (qty == 0)
            {
                qty = 1;
                dbUtil.SetPropertyValue(item, columnName, qty);
            }

            //Get Item Unit Price
            columnName = itemTablePrefix + "ProductUnitPrice";
            decimal unitPrice = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            //Get Item Discount Percent
            columnName = itemTablePrefix + "DiscountPercent";
            decimal discountPercent = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            //Set Item Discount Amount
            columnName = itemTablePrefix + "DiscountAmount";
            decimal discountAmount = qty * unitPrice * discountPercent / 100;

            dbUtil.SetPropertyValue(item, columnName, discountAmount);

            //Get Item Tax Percent
            columnName = itemTablePrefix + "TaxPercent";
            decimal taxPercent = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            //Set Item Tax Amount
            columnName = itemTablePrefix + "TaxAmount";
            decimal taxAmount = (qty * unitPrice - discountAmount) * taxPercent / 100;

            dbUtil.SetPropertyValue(item, columnName, taxAmount);

            //Set Item Total Amount
            columnName = itemTablePrefix + "TotalAmount";
            dbUtil.SetPropertyValue(item, columnName, qty * unitPrice - discountAmount + taxAmount);
        }
Example #28
0
        public virtual String GetMainObjectNo(ref int numberingStart)
        {
            String strMainObjectNo = String.Empty;
            GENumberingsController objGENumberingController = new GENumberingsController();
            GENumberingsInfo       objGENumberingInfo       = (GENumberingsInfo)objGENumberingController.GetObjectByName(Module.CurrentModuleName);

            if (objGENumberingInfo != null)
            {
                String mainTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
                BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(mainTableName + "Controller");
                if (objMainObjectController != null)
                {
                    VinaDbUtil    dbUtil              = new VinaDbUtil();
                    string        strPrefixHaveYear   = DateTime.Now.Year.ToString().Substring(2, 2);
                    List <string> subMainObjectNoList = new List <string>();
                    subMainObjectNoList.Add(objGENumberingInfo.GENumberingPrefix);
                    if (objGENumberingInfo.GENumberingPrefixHaveYear)
                    {
                        subMainObjectNoList.Add(strPrefixHaveYear);
                    }
                    subMainObjectNoList.Add(objGENumberingInfo.GENumberingNumber.ToString().PadLeft(objGENumberingInfo.GENumberingLength, '0'));

                    strMainObjectNo = string.Join(".", subMainObjectNoList.ToArray());

                    numberingStart = objGENumberingInfo.GENumberingNumber;
                    while (objMainObjectController.IsExist(strMainObjectNo))
                    {
                        objGENumberingInfo.GENumberingNumber++;

                        subMainObjectNoList.Clear();
                        subMainObjectNoList.Add(objGENumberingInfo.GENumberingPrefix);
                        if (objGENumberingInfo.GENumberingPrefixHaveYear)
                        {
                            subMainObjectNoList.Add(strPrefixHaveYear);
                        }
                        subMainObjectNoList.Add(objGENumberingInfo.GENumberingNumber.ToString().PadLeft(objGENumberingInfo.GENumberingLength, '0'));

                        strMainObjectNo = string.Join(".", subMainObjectNoList.ToArray());
                        numberingStart  = objGENumberingInfo.GENumberingNumber;
                    }
                }
            }
            return(strMainObjectNo);
        }
Example #29
0
        public static void RoundByCurrency(BusinessObject obj, string columnName, int currencyID)
        {
            VinaDbUtil dbUtil = new VinaDbUtil();

            GECurrenciesController currencyController = new GECurrenciesController();
            GECurrenciesInfo       currency           = currencyController.GetObjectByID(currencyID) as GECurrenciesInfo;

            if (currency != null && obj != null)
            {
                object  value  = dbUtil.GetPropertyValue(obj, columnName);
                decimal amount = 0;
                if (value != null)
                {
                    amount = Convert.ToDecimal(value);
                    amount = Math.Round(amount, currency.GECurrencyDecimalNumber);
                    dbUtil.SetPropertyValue(obj, columnName, amount);
                }
            }
        }
Example #30
0
        protected virtual RepositoryItemLookUpEdit InitColumnLookupEdit(string lookupTableName, string columnCaption)
        {
            if (!this.LookupTables.ContainsKey((object)lookupTableName))
            {
                GELookupTablesInfo objectByTableName = new GELookupTablesController().GetObjectByTableName(lookupTableName);
                if (objectByTableName != null)
                {
                    DataSet lookupTableData = ((IBaseModuleERP)this.Screen.Module).GetLookupTableData(lookupTableName);
                    this.LookupTables.Add((object)lookupTableName, (object)lookupTableData);
                    this.LookupTableObjects.Add(lookupTableName, objectByTableName);
                }
            }
            if (this.LookupTables[(object)lookupTableName] == null)
            {
                return((RepositoryItemLookUpEdit)null);
            }
            VinaDbUtil vinaDbUtil = new VinaDbUtil();
            RepositoryItemLookUpEdit repositoryItemLookUpEdit = new RepositoryItemLookUpEdit();

            repositoryItemLookUpEdit.BestFitMode   = BestFitMode.BestFitResizePopup;
            repositoryItemLookUpEdit.SearchMode    = SearchMode.AutoFilter;
            repositoryItemLookUpEdit.TextEditStyle = TextEditStyles.Standard;
            repositoryItemLookUpEdit.NullText      = string.Empty;
            repositoryItemLookUpEdit.Tag           = (object)lookupTableName;
            string tablePrimaryColumn = vinaDbUtil.GetTablePrimaryColumn(lookupTableName);
            string tableDisplayColumn = this.GetLookupTableDisplayColumn(lookupTableName);

            repositoryItemLookUpEdit.ValueMember   = tablePrimaryColumn;
            repositoryItemLookUpEdit.DisplayMember = tableDisplayColumn;
            repositoryItemLookUpEdit.DataSource    = (object)((DataSet)this.LookupTables[(object)lookupTableName]).Tables[0];
            repositoryItemLookUpEdit.Columns.Add(new LookUpColumnInfo()
            {
                Caption   = columnCaption,
                FieldName = repositoryItemLookUpEdit.DisplayMember,
                Width     = 100
            });
            //rep.QueryPopUp += new CancelEventHandler(this.RepositoryItemLookupEdit_QueryPopup);
            repositoryItemLookUpEdit.Leave += new System.EventHandler(this.RepositoryItemLookupEdit_Leave);
            //rep.QueryCloseUp += new CancelEventHandler(this.RepositoryItemLookupEdit_QueryCloseUp);
            repositoryItemLookUpEdit.KeyDown += new KeyEventHandler(this.RepositoryItemLookUpEdit_KeyDown);
            return(repositoryItemLookUpEdit);
        }