public List <WorkerAllocationEntity> GetDataFromDB(ProjectAllocationFramework.Statues.ProgressChangedEventHandler OnProgress, WorkerAllocationStatisticsSearchCondtion searchCondition = null)
        {
            List <WorkerAllocationEntity> entityList = new List <WorkerAllocationEntity>();

            string    sql = "select WorkerCode, WorkerName,count(distinct ProjectCode) As ProjectCount,sum(WorkerWorth) as WorthTotal FROM [ProjectAllocationCalc] WHERE 1=1 and WorkerCode like @WorkerCode and WorkerName like @WorkerName GROUP BY WorkerCode,WorkerName ORDER BY WorkerCode,WorkerName Asc";
            DbCommand cmd = DatabaseUtil.GetCommand(db.GetSqlStringCommand(sql));

            string workerCode = string.Empty;
            string workerName = string.Empty;

            if (searchCondition != null)
            {
                workerCode = searchCondition.WorkerCode.Trim();
                workerName = searchCondition.WorkerName.Trim();
            }

            db.AddInParameter(cmd, "WorkerCode", DbType.String, '%' + workerCode + '%');
            db.AddInParameter(cmd, "WorkerName", DbType.String, '%' + workerName + '%');

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    WorkerAllocationEntity item = new WorkerAllocationEntity();
                    item.WorkerCode   = ConvertUtil.ToString(reader["WorkerCode"]);
                    item.WorkerName   = ConvertUtil.ToString(reader["WorkerName"]);
                    item.ProjectCount = ConvertUtil.ToInt(reader["ProjectCount"]);
                    item.WorthTotal   = ConvertUtil.ToDouble(reader["WorthTotal"]);

                    item.Action   = Constant.ACTION_UPDATE;
                    item.ReadOnly = true;
                    //throw new Exception();
                    entityList.Add(item);
                }
            }
            return(entityList);
        }
Beispiel #2
0
        public List <WorkerAllocationEntity> GetData(params object[] paras)
        {
            this.EndEdit();
            List <WorkerAllocationEntity> entityList = new List <WorkerAllocationEntity>();
            int rowIdx = 1;

            foreach (DataGridViewRow item in this.Rows)
            {
                WorkerAllocationEntity entity = new WorkerAllocationEntity();
                entity.WorkerCode   = ConvertUtil.ToString(item.Cells[this.workerCodeColumn.Name].Value);
                entity.WorkerName   = ConvertUtil.ToString(item.Cells[this.workerNameColumn.Name].Value);
                entity.ProjectCount = ConvertUtil.ToInt(item.Cells[this.projectCountColumn.Name].Value);
                entity.WorthTotal   = ConvertUtil.ToDouble(item.Cells[this.worthTotalColumn.Name].Value);

                entity.ReadOnly = item.Cells[this.workerCodeColumn.Name].ReadOnly;
                entity.Row      = rowIdx;
                rowIdx++;
                if (!string.IsNullOrEmpty(entity.WorkerCode))
                {
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }