Exemplo n.º 1
0
        private void gvAP_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column.FieldName == MColName.Select)
            {
                DataRow row = gvAP.GetDataRow(e.RowHandle);
                LemAP.SqlUpdateLemAP((int)row[MColName.Id], (bool)row[MColName.Select] ? (int?)_headerRecord.Id : null);

                LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open);
            }
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
0
        private void SetSubmitStatus(EnumSubmitStatus status)
        {
            var row = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            if (row != null && row.GetValue(colSubmitStatus) != DBNull.Value && ConvertEx.StringToEnum <EnumSubmitStatus>(row.GetValueString(colSubmitStatus)) != status)
            {
                row.SetValue(colSubmitStatus, GetEnumName(status));
                LemHeader.SqlUpdateSubmitStatus(row.GetValue <int>(colId), status);
                btnSubmit.Enabled = (status == EnumSubmitStatus.Open);
            }
        }
Exemplo n.º 4
0
 public void LoadFromTemplate()
 {
     if (LabourTimeEntry.CopyDataFromTemplate(_headerRecord.ProjectId, _headerRecord.LogDate, _headerRecord.Id))
     {
         SetCurrent(_headerRecord);
         LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open);
     }
     else
     {
         GuiCommon.ShowMessage("The template data is not available.");
     }
 }
Exemplo n.º 5
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.º 6
0
 public void LoadFromPrevDay()
 {
     if (EquipTimeEntry.CopyDataFromPrevDay(_headerRecord.ProjectId, _headerRecord.LogDate, _headerRecord.Id))
     {
         SetCurrent(_headerRecord);
         LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open);
     }
     else
     {
         GuiCommon.ShowMessage("The previous day data is not available.");
     }
 }
Exemplo n.º 7
0
 private void gvLabour_RowDeleting(object sender, DevExpress.Data.RowDeletingEventArgs e)
 {
     if (GuiCommon.ShowMessage("Delete Record?", "Confirmation", PopupType.Yes_No) == PopupResult.No)
     {
         e.Cancel = true;
     }
     else
     {
         DataRow row = gvLabour.GetDataRow(e.RowHandle);
         LabourTimeEntry.DeleteEntry((int)row[colId.FieldName]);
         LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open);
     }
 }
Exemplo n.º 8
0
        private void gvLabour_RowUpdated(object sender, RowObjectEventArgs e)
        {
            if (gvLabour.IsNewItemRow(e.RowHandle))
            {
                DataRowView row = e.Row as DataRowView;
                row[colId.FieldName] = LabourTimeEntry.SqlInsert(_headerRecord.Id, (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], (bool)row[colManual.FieldName], (string)row[colWorkClass.FieldName], ConvertEx.ToNullable <decimal>(row[colIncludedHours.FieldName]),
                                                                 ConvertEx.ToNullable <decimal>(row[colTotalHours.FieldName]), ConvertEx.ToNullable <decimal>(row[colBillAmount.FieldName]));

                foreach (var timeCode in TimeCode.SubList(EnumValueType.Hours))
                {
                    LabourTimeDetail.SqlInsert((int)row[colId.FieldName], timeCode.MatchId, ConvertEx.ToNullable <decimal>(row[BillRateI(timeCode)]), ConvertEx.ToNullable <decimal>(row[EnterHoursI(timeCode)]), null);
                }

                foreach (var timeCode in TimeCode.SubList(EnumValueType.Dollars))
                {
                    LabourTimeDetail.SqlInsert((int)row[colId.FieldName], timeCode.MatchId, null, null, ConvertEx.ToNullable <decimal>(row[EnterAmountI(timeCode)]));
                }

                LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open);
            }
        }
Exemplo n.º 9
0
        private void gvEmployee_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            DataRow row      = gvLabour.GetDataRow(e.RowHandle);
            bool    needSave = false;

            if (e.Column == colEmpNum || e.Column == colEmployeeName)
            {
                int enmNum = (int)row[e.Column.FieldName];
                row[colEmpNum.FieldName]       = enmNum;
                row[colEmployeeName.FieldName] = enmNum;

                var wc = LabourTemplate.GetWorkClass(_headerRecord.ProjectId, enmNum, _headerRecord.LogDate);
                row[colWorkClass.FieldName] = wc ?? (object)Employee.GetEmployee(enmNum)?.WorkClassCode ?? DBNull.Value;
                needSave = true;
            }

            if (e.Column == colEmpNum || e.Column == colEmployeeName || e.Column == colWorkClass)
            {
                UpdateBillRate(row);
                CalcTotal(row);
                needSave = true;
            }

            if (e.Column == colManual)
            {
                bool manual = (bool)row[colManual.FieldName];
                if (!manual)
                {
                    foreach (var timeCode in TimeCode.SubList(TimeCode.EnumValueType.Hours))
                    {
                        row[EnterHoursI(timeCode)] = 0;
                    }
                    CalcTotal(row);
                }
                needSave = true;
            }

            if (e.Column == colLevel1Code)
            {
                row[colLevel2Code.FieldName] = DBNull.Value;
                row[colLevel3Code.FieldName] = DBNull.Value;
                row[colLevel4Code.FieldName] = DBNull.Value;
                needSave = true;
            }

            if (e.Column == colLevel2Code)
            {
                row[colLevel3Code.FieldName] = DBNull.Value;
                row[colLevel4Code.FieldName] = DBNull.Value;
                needSave = true;
            }

            if (e.Column == colLevel3Code)
            {
                row[colLevel4Code.FieldName] = DBNull.Value;
                needSave = true;
            }

            if (e.Column.FieldName.Contains(strEnterHours))
            {
                CalcOvertime(row, e.Column.FieldName);
                CalcTotal(row);
                needSave = true;
            }

            if (new GridColumn[] { colChangeOrder, colBillable }.Contains(e.Column))
            {
                needSave = true;
            }

            if (needSave && !gvLabour.IsNewItemRow(e.RowHandle))
            {
                LabourTimeEntry.SqlUpdate((int)row[colId.FieldName], (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], (bool)row[colManual.FieldName], (string)row[colWorkClass.FieldName], ConvertEx.ToNullable <decimal>(row[colIncludedHours.FieldName]), ConvertEx.ToNullable <decimal>(row[colTotalHours.FieldName]), ConvertEx.ToNullable <decimal>(row[colBillAmount.FieldName]));
                row.AcceptChanges();

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