Exemplo n.º 1
0
        public IHttpActionResult Get(int companyId)
        {
            try
            {
                string sql = $"select w.Id, w.Description, w.ValueType, isnull(w.BillingRateType, 'Unknown')[BillingRateType], " +
                             $"w.InclInHoursThisWeek, w.Time_Code_ID_OT, w.Time_Code_ID_DT, e.comp_code[Component], ReportTypeColumn from WS_EMP_Time_Code w " +
                             $"join earn_code e on e.eg_code = w.eg_code and e.ec_code = w.ec_code";

                DataTable table = SqlCommon.ExecuteDataAdapter(sql, WebCommon.GetTRConnectionAsync(companyId));

                List <TimeCode> list = new List <TimeCode>();
                table.Select().ToList().ForEach(r => list.Add(new TimeCode
                {
                    MatchId            = (int)r["Id"],
                    CompanyId          = companyId,
                    Desc               = $"{r["Description"]}",
                    ValueType          = ConvertEx.StringToEnum <EnumValueType>(r["ValueType"]),
                    BillingType        = ConvertEx.StringToEnum <EnumBillingRateType>(r["BillingRateType"]),
                    OvertimeId         = r.Field <int?>("Time_Code_ID_OT"),
                    DoubleTimeId       = r.Field <int?>("Time_Code_ID_DT"),
                    IncludedInWeekCalc = (bool)r["InclInHoursThisWeek"],
                    Component          = ConvertEx.CharToEnum <EnumComponentType>(r["Component"]),
                    ReportTypeColumn   = Convert.ToString(r["ReportTypeColumn"])
                }));

                return(Ok(list));
            }
            catch (Exception e)
            {
                SqlCommon.ReportInfo(e.Message);
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult Get(int companyId)
        {
            try
            {
                string    sql   = "select eqi_num, eqi_code, eqi_desc1, eqi_class, eqi_cat, isnull(own_type,'U') own_type from Equip_ID";
                DataTable table = SqlCommon.ExecuteDataAdapter(sql, WebCommon.GetTRConnectionAsync(companyId));

                List <Equipment> list = new List <Equipment>();
                table.Select().ToList().ForEach(r => list.Add(new Equipment
                {
                    EqpNum       = (string)r["eqi_num"],
                    CompanyId    = companyId,
                    AssetCode    = (string)r["eqi_code"],
                    Desc         = (string)r["eqi_desc1"],
                    ClassCode    = (string)r["eqi_class"],
                    CategoryCode = (string)r["eqi_cat"],
                    OwnerType    = ConvertEx.CharToEnum <EnumOwnerType>(r["own_type"])
                }));

                return(Ok(list));
            }
            catch (Exception e)
            {
                SqlCommon.ReportInfo(e.Message);
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 3
0
        public IHttpActionResult Get()
        {
            try
            {
                string    sql   = $"select * from COMPANIES";
                DataTable table = SqlCommon.ExecuteDataAdapter(sql, WebCommon.WebConnection);

                List <Company> list = new List <Company>();
                table.Select().ToList().ForEach(r => list.Add(new Company
                {
                    MatchId     = (int)r["AutoID"],
                    CompanyName = (string)r["Company_Name"],
                    ShortName   = ConvertEx.StrOrEmpty(r["companyShortName"]),
                    Active      = (bool)r["Active"],
                }));

                foreach (var com in list)
                {
                    sql   = @"select * from Company";
                    table = SqlCommon.ExecuteDataAdapter(sql, WebCommon.GetTRConnectionAsync(com.MatchId));
                    com.CompanyAddress1 = Convert.ToString(table.Rows[0]["ADD1"]);
                    com.CompanyAddress2 = Convert.ToString(table.Rows[0]["ADD2"]);
                    com.CompanyAddress3 = Convert.ToString(table.Rows[0]["ADD3"]);
                    com.CompanyCity     = Convert.ToString(table.Rows[0]["City"]);
                    com.CompanyState    = Convert.ToString(table.Rows[0]["State"]);
                    com.CompanyZip      = Convert.ToString(table.Rows[0]["Zip"]);
                    com.CompanyPhone    = Convert.ToString(table.Rows[0]["Phone"]);
                    com.CompanyFax      = Convert.ToString(table.Rows[0]["Fax"]);
                    com.CompanyEmail    = Convert.ToString(table.Rows[0]["Email"]);
                    com.CompanyWeb      = Convert.ToString(table.Rows[0]["WebPage"]);

                    sql = "select isnull(case when rtrim(week_start) = '' then null else week_start end, 'U') as week_start from hr_cntl";
                    EnumDayInWeek day = ConvertEx.CharToEnum <EnumDayInWeek>(SqlCommon.ExecuteScalar(sql, WebCommon.GetTRConnectionAsync(com.MatchId)));
                    com.WeekStart = ConvertEx.StringToEnum <DayOfWeek>(Enum.GetName(typeof(EnumDayInWeek), day));

                    sql   = @"select use_cat_class from fa_setup";
                    table = SqlCommon.ExecuteDataAdapter(sql, WebCommon.GetTRConnectionAsync(com.MatchId));
                    com.EquipRateGroupType = (EnumGroupType)Convert.ToChar(table.Rows[0]["use_cat_class"]);

                    sql              = @"select lv1_active_gc, lv1_gencon_desc, lv2_active_gc, lv2_gencon_desc, lv3_active_gc, lv3_gencon_desc, lv4_active_gc, lv4_gencon_desc from proj_cntl";
                    table            = SqlCommon.ExecuteDataAdapter(sql, WebCommon.GetTRConnectionAsync(com.MatchId));
                    com.MaxLevelCode = (table.Rows[0]["lv4_active_gc"] != DBNull.Value ? 4 :
                                        (table.Rows[0]["lv3_active_gc"] != DBNull.Value ? 3 :
                                         (table.Rows[0]["lv2_active_gc"] != DBNull.Value ? 2 :
                                          (table.Rows[0]["lv1_active_gc"] != DBNull.Value ? 1 : 0))));
                    com.Level1CodeDesc = Convert.ToString(table.Rows[0]["lv1_gencon_desc"]);
                    com.Level2CodeDesc = Convert.ToString(table.Rows[0]["lv2_gencon_desc"]);
                    com.Level3CodeDesc = Convert.ToString(table.Rows[0]["lv3_gencon_desc"]);
                    com.Level4CodeDesc = Convert.ToString(table.Rows[0]["lv4_gencon_desc"]);
                }

                return(Ok(list));
            }
            catch (Exception e)
            {
                SqlCommon.ReportInfo(e.Message);
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 4
0
        private void gvDetail_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            if (gvDetail.IsNewItemRow(e.RowHandle))
            {
                int         poId = (int)gvPO.GetFocusedDataRow()[colId.FieldName];
                DataRowView row  = e.Row as DataRowView;
                row[colDetailId.FieldName] = FieldPODetail.SqlInsert(poId, (int)row[colDetailPOLine.FieldName], (string)row[colDetailDescription.FieldName],
                                                                     ConvertEx.ToNullable <int>(row[colDetailLevel1Code.FieldName]), ConvertEx.ToNullable <int>(row[colDetailLevel2Code.FieldName]),
                                                                     ConvertEx.ToNullable <int>(row[colDetailLevel3Code.FieldName]), ConvertEx.ToNullable <int>(row[colDetailLevel4Code.FieldName]),
                                                                     ConvertEx.CharToEnum <EnumComponentType>(row[colDetailComponent.FieldName]), (bool)row[colDetailBillable.FieldName], (decimal)row[colDetailAmount.FieldName]);

                SetSubmitStatus(EnumSubmitStatus.Open);
            }
        }
Exemplo n.º 5
0
 public LemHeader(DataRow row)
 {
     Id               = (int)row["Id"];
     MatchId          = (int)row["MatchId"];
     CompanyId        = (int)row["CompanyId"];
     LogDate          = Convert.ToDateTime(row["LogDate"]);
     LogStatus        = ConvertEx.CharToEnum <EnumLogStatus>(row["LogStatus"]);
     SubmitStatus     = ConvertEx.CharToEnum <EnumSubmitStatus>(row["SubmitStatus"]);
     ProjectId        = (int)row["ProjectId"];
     LemNum           = Convert.ToString(row["LemNum"]);
     CreatorId        = Convert.ToInt32(row["CreatorId"]);
     Description      = Convert.ToString(row["LEM_Desc"]);
     ApprovalComments = Convert.ToString(row["ApprovalComments"]);
     EmailData        = ConvertEx.ToNullableObj <byte[]>(row["EmailData"]);
 }
Exemplo n.º 6
0
 public FieldPODetail(DataRow row)
 {
     Id          = Convert.ToInt32(row["Id"]);
     CompanyId   = Convert.ToInt32(row["CompanyId"]);
     POId        = Convert.ToInt32(row["POId"]);
     LineNum     = Convert.ToInt16(row["LineNum"]);
     Description = Convert.ToString(row["Description"]);
     Level1Id    = ConvertEx.ToNullable <int>(row["Level1Code"]);
     Level2Id    = ConvertEx.ToNullable <int>(row["Level2Code"]);
     Level3Id    = ConvertEx.ToNullable <int>(row["Level3Code"]);
     Level4Id    = ConvertEx.ToNullable <int>(row["Level4Code"]);
     Component   = ConvertEx.CharToEnum <EnumComponentType>(row["Component"]);
     Billable    = Convert.ToBoolean(row["Billable"]);
     Amount      = Convert.ToDecimal(row["Amount"]);
 }
Exemplo n.º 7
0
        public FieldPO(DataRow row)
        {
            Id           = Convert.ToInt32(row["Id"]);
            MatchId      = Convert.ToInt32(row["MatchId"]);
            CompanyId    = Convert.ToInt32(row["CompanyId"]);
            PODate       = Convert.ToDateTime(row["PODate"]);
            PONum        = Convert.ToString(row["PONum"]);
            SupplierCode = Convert.ToString(row["SupplierCode"]);
            ProjectId    = Convert.ToInt32(row["ProjectId"]);
            Billable     = Convert.ToBoolean(row["Billable"]);

            POAmount     = Convert.ToDecimal(row["POAmount"]);
            SubmitStatus = ConvertEx.CharToEnum <EnumSubmitStatus>(row["FieldPOStatus"]);
            CreatorId    = Convert.ToInt32(row["CreatorId"]);
        }
Exemplo n.º 8
0
        void RefreshBillRate(DataRow row)
        {
            var equip = Equipment.GetEquipment(Convert.ToString(row[colEqpNum.FieldName]));

            if (equip != null && row[colBillCycle.FieldName] != DBNull.Value)
            {
                EnumBillCycle cycle = ConvertEx.CharToEnum <EnumBillCycle>(row[colBillCycle.FieldName]);
                var           list  = equip.GetBillRateList(_headerRecord.ProjectId);
                row[colBillRate.FieldName] = (object)list.SingleOrDefault(x => x.BillCycle == cycle)?.BillRate ?? DBNull.Value;
            }
            else
            {
                row[colBillRate.FieldName] = DBNull.Value;
            }
            RefreshBillAmount(row);
        }
Exemplo n.º 9
0
 public EquipTimeEntry(DataRow row)
 {
     Id            = (int)row["Id"];
     MatchId       = (int)row["MatchId"];
     CompanyId     = (int)row["CompanyId"];
     HeaderId      = (int)row["LogHeaderId"];
     EqpNum        = (string)row["EqpNum"];
     EmpNum        = ConvertEx.ToNullable <int>(row["EmpNum"]);
     ChangeOrderId = ConvertEx.ToNullable <int>(row["ChangeOrderId"]);
     Level1Id      = ConvertEx.ToNullable <int>(row["Level1Id"]);
     Level2Id      = ConvertEx.ToNullable <int>(row["Level2Id"]);
     Level3Id      = ConvertEx.ToNullable <int>(row["Level3Id"]);
     Level4Id      = ConvertEx.ToNullable <int>(row["Level4Id"]);
     Billable      = (bool)row["Billable"];
     Quantity      = Convert.ToDecimal(row["Quantity"]);
     BillCycle     = ConvertEx.CharToEnum <EnumBillCycle>(row["BillCycle"]);
     BillAmount    = ConvertEx.ValueOrZero <decimal>(row["BillAmount"]);
 }
Exemplo n.º 10
0
        public IHttpActionResult Get(int contactId, int companyId)
        {
            try
            {
                using (SqlConnection sqlcon = new SqlConnection(WebCommon.WebConnection))
                {
                    sqlcon.Open();

                    string sSQL = @"WS_FLEM_Defaults_Get";
                    using (SqlCommand cmd = new SqlCommand(sSQL, sqlcon))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@contactId", contactId));
                        cmd.Parameters.Add(new SqlParameter("@CompanyId", companyId));

                        DataTable table = new DataTable();
                        table.Load(cmd.ExecuteReader());

                        List <DefaultEarning> list = table.Select().Select(r => new DefaultEarning
                        {
                            CompanyId   = companyId,
                            ProjectId   = Convert.ToInt32(r["pri_id"]),
                            Level1Id    = ConvertEx.ToNullable <int>(r["lv1id"]),
                            Level2Id    = ConvertEx.ToNullable <int>(r["lv2id"]),
                            Level3Id    = ConvertEx.ToNullable <int>(r["lv3id"]),
                            Level4Id    = ConvertEx.ToNullable <int>(r["lv4id"]),
                            EarningType = ConvertEx.CharToEnum <EnumEarningType>(r["type"])
                        }).ToList();

                        return(Ok(list));
                    }
                }
            }
            catch (Exception e)
            {
                SqlCommon.ReportInfo(e.Message);
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 11
0
        private void gvDetail_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            DataRow row = gvDetail.GetDataRow(e.RowHandle);

            if (e.Column == colDetailLevel1Code)
            {
                row[colDetailLevel2Code.FieldName] = DBNull.Value;
                row[colDetailLevel3Code.FieldName] = DBNull.Value;
                row[colDetailLevel4Code.FieldName] = DBNull.Value;
            }
            else if (e.Column == colDetailLevel2Code)
            {
                row[colDetailLevel3Code.FieldName] = DBNull.Value;
                row[colDetailLevel4Code.FieldName] = DBNull.Value;
            }
            else if (e.Column == colDetailLevel3Code)
            {
                row[colDetailLevel4Code.FieldName] = DBNull.Value;
            }
            else if (e.Column == colDetailAmount)
            {
                UpdatePOAmount();
            }

            if (!gvDetail.IsNewItemRow(e.RowHandle))
            {
                if (new GridColumn[] { colDetailDescription, colDetailLevel1Code, colDetailLevel2Code, colDetailLevel3Code, colDetailLevel4Code, colDetailComponent, colDetailBillable, colDetailAmount }.Contains(e.Column))
                {
                    FieldPODetail.SqlUpdate((int)row[colDetailId.FieldName], (string)row[colDetailDescription.FieldName],
                                            ConvertEx.ToNullable <int>(row[colDetailLevel1Code.FieldName]), ConvertEx.ToNullable <int>(row[colDetailLevel2Code.FieldName]),
                                            ConvertEx.ToNullable <int>(row[colDetailLevel3Code.FieldName]), ConvertEx.ToNullable <int>(row[colDetailLevel4Code.FieldName]),
                                            ConvertEx.CharToEnum <EnumComponentType>(row[colDetailComponent.FieldName]), (bool)row[colDetailBillable.FieldName], (decimal)row[colDetailAmount.FieldName]);

                    SetSubmitStatus(EnumSubmitStatus.Open);
                }
            }
        }
Exemplo n.º 12
0
        private void gvEquipment_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            if (gvEquipment.IsNewItemRow(e.RowHandle))
            {
                DataRowView row = e.Row as DataRowView;
                row[colId.FieldName] = EquipTimeEntry.SqlInsert(_headerRecord.Id, (string)row[colEqpNum.FieldName], ConvertEx.ToNullable <int>(row[colEmpNum.FieldName]), ConvertEx.ToNullable <int>(row[colChangeOrder.FieldName]),
                                                                ConvertEx.ToNullable <int>(row[colLevel1Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel2Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel3Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel4Code.FieldName]),
                                                                (bool)row[colBillable.FieldName], ConvertEx.ToNullable <decimal>(row[colQuantity.FieldName]) ?? 0, ConvertEx.CharToEnum <EnumBillCycle>(row[colBillCycle.FieldName]), ConvertEx.ToNullable <decimal>(row[colBillAmount.FieldName]));

                LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open);
            }
        }
Exemplo n.º 13
0
        private void gvEquipment_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            DataRow row = gvEquipment.GetDataRow(e.RowHandle);

            if (e.Column == colEqpNum || e.Column == colAssetDescription)
            {
                string eqtNum = Convert.ToString(row[e.Column.FieldName]);
                row[colEqpNum.FieldName]           = eqtNum;
                row[colAssetDescription.FieldName] = eqtNum;
                var equip = Equipment.GetEquipment(eqtNum);
                row[colEquipmentClass.FieldName] = EquipmentClass.GetEquipmentClass(equip.ClassCode)?.DisplayName ?? "";

                Employee employee = (equip.OwnerType == EnumOwnerType.Employee) ? EquipmentAssignment.GetEmployee(equip.EqpNum, _headerRecord.LogDate) : null;
                row[colEmpNum.FieldName]       = (object)employee?.EmpNum ?? DBNull.Value;
                row[colEmployeeName.FieldName] = employee?.DisplayName ?? "";

                RefreshBillRate(row);
            }
            else if (e.Column == colLevel1Code)
            {
                row[colLevel2Code.FieldName] = DBNull.Value;
                row[colLevel3Code.FieldName] = DBNull.Value;
                row[colLevel4Code.FieldName] = DBNull.Value;
            }
            else if (e.Column == colLevel2Code)
            {
                row[colLevel3Code.FieldName] = DBNull.Value;
                row[colLevel4Code.FieldName] = DBNull.Value;
            }
            else if (e.Column == colLevel3Code)
            {
                row[colLevel4Code.FieldName] = DBNull.Value;
            }
            else if (e.Column == colBillCycle)
            {
                RefreshBillRate(row);
            }
            else if (e.Column == colQuantity)
            {
                RefreshBillAmount(row);
            }

            if (!gvEquipment.IsNewItemRow(e.RowHandle))
            {
                if (new GridColumn[] { colEqpNum, colAssetDescription, colChangeOrder, colLevel1Code, colLevel2Code, colLevel3Code, colLevel4Code, colBillable, colQuantity, colBillCycle }.Contains(e.Column))
                {
                    EquipTimeEntry.SqlUpdate((int)row[colId.FieldName], (string)row[colEqpNum.FieldName], ConvertEx.ToNullable <int>(row[colEmpNum.FieldName]), ConvertEx.ToNullable <int>(row[colChangeOrder.FieldName]),
                                             ConvertEx.ToNullable <int>(row[colLevel1Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel2Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel3Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel4Code.FieldName]),
                                             (bool)row[colBillable.FieldName], ConvertEx.ToNullable <decimal>(row[colQuantity.FieldName]) ?? 0, ConvertEx.CharToEnum <EnumBillCycle>(row[colBillCycle.FieldName]), ConvertEx.ToNullable <decimal>(row[colBillAmount.FieldName]));

                    LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open);
                }
            }
        }