Beispiel #1
0
        private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            if (new GridColumn[] { colProjectCode, colProjectName }.Contains(e.Column))
            {
                DataRow row       = gridView1.GetDataRow(e.RowHandle);
                int     projectId = row.GetValue <int>(e.Column);
                Project project   = Project.GetProject(projectId);

                row.SetValue(colProjectCode, projectId);
                row.SetValue(colProjectName, projectId);
                row.SetValue(colCustomerCode, project?.CustomerCode);
                row.SetValue(colCustomerName, project?.CustomerName);
                row.SetValue(colSiteLocation, project?.SiteLocation);
                row.SetValue(colStartDate, StrEx.GetDateString(project?.StartDate));
                row.SetValue(colEstCompletionDate, StrEx.GetDateString(project?.EstCompletionDate));

                row.SetValue(colLemNum, project.GetNextLemNum());
            }

            if (!gridView1.IsNewItemRow(e.RowHandle))
            {
                if (new GridColumn[] { colProjectCode, colProjectName, colLogDate, colLogStatus, colDescription }.Contains(e.Column))
                {
                    DataRow row = gridView1.GetDataRow(e.RowHandle);
                    row.SetValue(colSubmitStatus, GetEnumName(EnumSubmitStatus.Open));
                    LemHeader.SqlUpdate(row.GetValue <int>(colId), row.GetValue <DateTime>(colLogDate), row.GetValue <int>(colProjectCode),
                                        row.GetCharEnumValue <EnumLogStatus>(colLogStatus), row.GetValueString(colDescription));
                }
            }
        }
Beispiel #2
0
        public static void SqlUpdate(int id, DateTime poDate, string poNum, string supplierCode, int projectId, bool billable)
        {
            string sql = $"update FieldPO set POdate='{poDate}', PONum='{StrEx.SqlEsc(poNum)}', SupplierCode='{supplierCode}', projectId={projectId}, " +
                         $"Billable='{billable}', FieldPOStatus='{(char)EnumSubmitStatus.Open}', SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id}";

            MobileCommon.ExecuteNonQuery(sql);
        }
Beispiel #3
0
        public static void SqlUpdate(int id, string desc, int?level1Id, int?level2Id, int?level3Id, int?level4Id, EnumComponentType component, bool billable, decimal amount)
        {
            string sql = $"update FieldPODetail set Description='{desc}', Level1Code={StrEx.ValueOrNull(level1Id)}, Level2Code={StrEx.ValueOrNull(level2Id)}, " +
                         $"Level3Code={StrEx.ValueOrNull(level3Id)}, Level4Code={StrEx.ValueOrNull(level4Id)}, Component='{(char)component}', Billable='{billable}', Amount={amount} where id={id} ";

            MobileCommon.ExecuteNonQuery(sql);
        }
Beispiel #4
0
        public List <Attachment> GetSendList()
        {
            List <SyncCoreMatch> matchList = SyncCoreMatch.GetMatchList("LemHeader");
            string linkIds = StrEx.GetIdListText(matchList.Select(x => x.SourceId).ToList());

            string sql = $"select r.*, l.CompanyId, l.MatchId, l.ContextItem_ID, l.TableDotField, l.IdValue, l.Comment from CFS_FileRepository r join CFS_FileLink l on l.FileRepository_ID = r.ID " +
                         $"where TableDotField='{Attachment.LemHeaderId}' and IdValue in ({linkIds}) and (SyncStatus='{EnumRecordSyncStatus.NoSubmit}' or SyncStatus is null)";
            DataTable         table   = MobileCommon.ExecuteDataAdapter(sql);
            List <Attachment> listLem = table.Select().Select(r => new Attachment(r)).ToList();

            listLem.ForEach(x => x.LinkMatchId = matchList.Single(m => m.SourceId == x.LinkMatchId).MatchId);

            matchList = SyncCoreMatch.GetMatchList("FieldPO");
            linkIds   = StrEx.GetIdListText(matchList.Select(x => x.SourceId).ToList());

            sql = $"select r.*, l.CompanyId, l.MatchId, l.ContextItem_ID, l.TableDotField, l.IdValue, l.Comment from CFS_FileRepository r join CFS_FileLink l on l.FileRepository_ID = r.ID " +
                  $"where TableDotField='{Attachment.FieldPOId}' and IdValue in ({linkIds}) and (SyncStatus='{EnumRecordSyncStatus.NoSubmit}' or SyncStatus is null)";
            table = MobileCommon.ExecuteDataAdapter(sql);
            List <Attachment> listPo = table.Select().Select(r => new Attachment(r)).ToList();

            listPo.ForEach(x => x.LinkMatchId = matchList.Single(m => m.SourceId == x.LinkMatchId).MatchId);

            listLem.AddRange(listPo);
            return(listLem);
        }
        public static int SqlInsert(int entryId, int timecodeId, decimal?billRate, decimal?workHours, decimal?amount)
        {
            string sql = $"Insert LabourTimeDetail(CompanyId, EntryId, TimeCodeId, BillRate, WorkHours, Amount) " +
                         $"values({Company.CurrentId}, {entryId}, {timecodeId}, {StrEx.ValueOrNull(billRate)}, {StrEx.ValueOrNull(workHours)}, {StrEx.ValueOrNull(amount)}); " +
                         $"Select CAST(SCOPE_IDENTITY() AS INT);";

            return(Convert.ToInt32(MobileCommon.ExecuteScalar(sql)));
        }
Beispiel #6
0
        public static void SqlUpdate(int id, int empNum, int?changeOrderId, int?level1Id, int?level2Id, int?level3Id, int?level4Id, bool billable, bool manual, string workClassCode, decimal?includedHours, decimal?totalHours, decimal?billAmount)
        {
            string sql = $"update LabourTimeEntry set EmpNum={empNum}, ChangeOrderId={StrEx.ValueOrNull(changeOrderId)}, Level1Id={StrEx.ValueOrNull(level1Id)}, Level2Id={StrEx.ValueOrNull(level2Id)}, " +
                         $"Level3Id={StrEx.ValueOrNull(level3Id)}, Level4Id={StrEx.ValueOrNull(level4Id)}, Billable='{billable}', Manual='{manual}', WorkClassCode='{workClassCode}', " +
                         $"IncludedHours={StrEx.ValueOrNull(includedHours)}, TotalHours={StrEx.ValueOrNull(totalHours)}, BillAmount={StrEx.ValueOrNull(billAmount)}, SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id} ";

            MobileCommon.ExecuteNonQuery(sql);
        }
Beispiel #7
0
        public static void SqlUpdate(int id, string eqpNum, int?empNum, int?changeOrderId, int?level1Id, int?level2Id, int?level3Id, int?level4Id, bool billable, decimal quantity, EnumBillCycle billCycle, decimal?billAmount)
        {
            string sql = $"update EquipTimeEntry set EqpNum={eqpNum}, EmpNum={StrEx.ValueOrNull(empNum)}, Billable='{billable}', ChangeOrderId={StrEx.ValueOrNull(changeOrderId)}, " +
                         $"Level1Id={StrEx.ValueOrNull(level1Id)}, Level2Id={StrEx.ValueOrNull(level2Id)}, Level3Id={StrEx.ValueOrNull(level3Id)}, Level4Id={StrEx.ValueOrNull(level4Id)}, " +
                         $"Quantity={quantity}, BillCycle='{(char)billCycle}', BillAmount={StrEx.ValueOrNull(billAmount)}, SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id} ";

            MobileCommon.ExecuteNonQuery(sql);
        }
Beispiel #8
0
        public static int SqlInsert(int headerId, int empNum, int?changeOrderId, int?level1Id, int?level2Id, int?level3Id, int?level4Id, bool billable, bool manual, string workClassCode, decimal?includedHours, decimal?totalHours, decimal?billAmount)
        {
            string sql = $"insert LabourTimeEntry(MatchId, CompanyId, LogHeaderId, EmpNum, ChangeOrderId, Level1Id, Level2Id, Level3Id, Level4Id, Billable, Manual, WorkClassCode, IncludedHours, TotalHours, BillAmount, SyncStatus, Deleted) " +
                         $"values(-1, {Company.CurrentId}, {headerId}, {empNum}, {StrEx.ValueOrNull(changeOrderId)}, {StrEx.ValueOrNull(level1Id)}, {StrEx.ValueOrNull(level2Id)}, " +
                         $"{StrEx.ValueOrNull(level3Id)}, {StrEx.ValueOrNull(level4Id)}, '{billable}', '{manual}', '{workClassCode}', {StrEx.ValueOrNull(includedHours)}, {StrEx.ValueOrNull(totalHours)}, {StrEx.ValueOrNull(billAmount)}, '{EnumRecordSyncStatus.NoSubmit}', 0); " +
                         $"Select CAST(SCOPE_IDENTITY() AS INT);";

            return(Convert.ToInt32(MobileCommon.ExecuteScalar(sql)));
        }
Beispiel #9
0
        public static int SqlInsert(int headerId, string eqpNum, int?empNum, int?changeOrderId, int?level1Id, int?level2Id, int?level3Id, int?level4Id, bool billable, decimal quantity, EnumBillCycle billCycle, decimal?billAmount)
        {
            string sql = $"insert EquipTimeEntry(MatchId, CompanyId, LogHeaderId, EqpNum, EmpNum, changeOrderId, Level1Id, Level2Id, Level3Id, Level4Id, Billable, Quantity, BillCycle, BillAmount, SyncStatus, Deleted) " +
                         $"values(-1, {Company.CurrentId}, {headerId}, {eqpNum}, {StrEx.ValueOrNull(empNum)}, {StrEx.ValueOrNull(changeOrderId)}, {StrEx.ValueOrNull(level1Id)}, {StrEx.ValueOrNull(level2Id)}, {StrEx.ValueOrNull(level3Id)}, {StrEx.ValueOrNull(level4Id)}," +
                         $" '{billable}', {quantity}, '{(char)billCycle}', {StrEx.ValueOrNull(billAmount)}, '{EnumRecordSyncStatus.NoSubmit}', 0); " +
                         $"Select CAST(SCOPE_IDENTITY() AS INT);";

            return(Convert.ToInt32(MobileCommon.ExecuteScalar(sql)));
        }
Beispiel #10
0
        public static int SqlInsert(int poId, int lineNum, string desc, int?level1Id, int?level2Id, int?level3Id, int?level4Id, EnumComponentType component, bool billable, decimal amount)
        {
            string sql = $"insert FieldPODetail(CompanyId, POId, LineNum, Description, Level1Code, Level2Code, Level3Code, Level4Code, Component, Billable, Amount) " +
                         $"values({Company.CurrentId}, {poId}, {lineNum}, '{desc}', {StrEx.ValueOrNull(level1Id)}, {StrEx.ValueOrNull(level2Id)}," +
                         $" {StrEx.ValueOrNull(level3Id)}, {StrEx.ValueOrNull(level4Id)}, '{(char)component}', '{billable}', {amount}); " +
                         $"Select CAST(SCOPE_IDENTITY() AS INT);";

            return(Convert.ToInt32(MobileCommon.ExecuteScalar(sql)));
        }
Beispiel #11
0
        public static DataTable GetCostCodeSummary(List <int> headerIds)
        {
            string idText = StrEx.GetIdListText(headerIds);

            string sql = $"select e.EmpNum, WorkClassCode, e.Billable, ProjectId, ChangeOrderId, Level1Id, Level2Id, Level3Id, Level4Id, d.TimeCodeId, Sum(d.WorkHours) SumWorkHour, Sum(d.Amount) SumAmount " +
                         $"from Lemheader h join LabourTimeEntry e on e.LogHeaderId = h.id " +
                         $"join LabourTimeDetail d on e.id = d.EntryId " +
                         $"where h.Deleted = 0 and e.Deleted = 0 and h.Id in ({idText})" +
                         $"group by e.EmpNum, e.WorkClassCode, e.Billable, ProjectId, ChangeOrderId, Level1Id, Level2Id, Level3Id, Level4Id, d.TimeCodeId ";

            return(MobileCommon.ExecuteDataAdapter(sql));
        }
Beispiel #12
0
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    var query = HttpUtility.ParseQueryString(string.Empty);
                    query["companyId"] = CompanyId.ToString();
                    query["clientMac"] = MobileCommon.MachineMac;
                    HttpResponseMessage response = await client.GetAsync($"api/LemAP?{query.ToString()}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <LemAP> list = await response.Content.ReadAsAsync <List <LemAP> >();

                        list.ForEach(x =>
                        {
                            BeforeReceiveRecord(x.MatchId);

                            string sql = $"insert LemAp(MatchId, CompanyId, ProjectId, InvoiceDate, LogHeaderId, InvoiceNum, SupplierCode, PONum, InvoiceAmount, MarkupAmount, BillAmount, SyncStatus) " +
                                         $"values({x.MatchId}, {x.CompanyId}, {x.ProjectId}, '{x.InvoiceDate}', null, '{x.InvoiceNum}', '{x.SupplierCode}', '{x.PONum}', {x.InvoiceAmount}, {x.MarkupAmount}, {x.BillAmount}, '{EnumRecordSyncStatus.Receiving}'); " +
                                         $"Select CAST(SCOPE_IDENTITY() AS INT);";

                            int mid = Convert.ToInt32(MobileCommon.ExecuteScalar(sql));
                            foreach (var d in x.DetailList)
                            {
                                sql = $"insert LemAPDetail(MatchId, CompanyId, LemAPId, LineNum, Description, Reference, Amount, MarkupPercent, MarkupAmount, BillAmount, Level1Id, Level2Id, Level3Id, Level4Id) " +
                                      $"values({d.MatchId}, {d.CompanyId}, {mid}, {d.LineNum}, '{d.Description}', '{d.Reference}', {d.Amount}, {d.MarkupPercent}, {d.MarkupAmount}, {d.BillAmount}, " +
                                      $"{StrEx.ValueOrNull(d.Level1Id)}, {StrEx.ValueOrNull(d.Level2Id)}, {StrEx.ValueOrNull(d.Level3Id)}, {StrEx.ValueOrNull(d.Level4Id)});";
                                MobileCommon.ExecuteNonQuery(sql);
                            }
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
Beispiel #13
0
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    var query = HttpUtility.ParseQueryString(string.Empty);
                    query["companyId"] = CompanyId.ToString();
                    query["clientMac"] = MobileCommon.MachineMac;
                    query["contactId"] = LoginUser.CurrUser.MatchId.ToString();
                    HttpResponseMessage response = await client.GetAsync($"api/LabourTimeEntry?{query.ToString()}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        var list = await response.Content.ReadAsAsync <List <LabourTimeEntry> >();

                        list.ForEach(x =>
                        {
                            BeforeReceiveRecord(x.MatchId);

                            string sql = $"insert LabourTimeEntry(MatchId, CompanyId, LogHeaderId, EmpNum, ChangeOrderId, Level1Id, Level2Id, Level3Id, Level4Id, Billable, Manual, WorkClassCode, IncludedHours, TotalHours, BillAmount, SyncStatus, Deleted) " +
                                         $"values({x.MatchId}, {x.CompanyId}, {x.HeaderId}, {x.EmpNum}, {StrEx.ValueOrNull(x.ChangeOrderId)}, {StrEx.ValueOrNull(x.Level1Id)}, {StrEx.ValueOrNull(x.Level2Id)}, " +
                                         $"{StrEx.ValueOrNull(x.Level3Id)}, {StrEx.ValueOrNull(x.Level4Id)}, '{x.Billable}', '{x.Manual}', '{x.WorkClassCode}', {StrEx.ValueOrNull(x.IncludedHours)}, {StrEx.ValueOrNull(x.TotalHours)}, {StrEx.ValueOrNull(x.BillAmount)}, '{EnumRecordSyncStatus.Receiving}', 0); " +
                                         $"Select CAST(SCOPE_IDENTITY() AS INT);";

                            int entryId = Convert.ToInt32(MobileCommon.ExecuteScalar(sql));
                            foreach (var d in x.DetailList)
                            {
                                LabourTimeDetail.SqlInsert(entryId, d.TimeCodeId, d.BillRate, d.WorkHours, d.Amount);
                            }
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
Beispiel #14
0
        public static decimal GetDayHours(int projectId, int empNum, DateTime currDate, int?currId)
        {
            var    regCodeIds    = TimeCode.ListForCompany().Where(x => x.BillingType == TimeCode.EnumBillingRateType.Regular).Select(x => x.MatchId).ToList();
            string txtRegCodeIds = StrEx.GetIdListText(regCodeIds);

            string sql = $"select isnull(sum(d.WorkHours), 0.0) from LemHeader h " +
                         $"join LabourTimeEntry e on h.Id = e.LogHeaderId " +
                         $"join LabourTimeDetail d on e.Id = d.EntryId " +
                         $"where h.projectId={projectId} and h.LogDate='{currDate}' and h.deleted=0 and e.EmpNum = {empNum} and e.deleted=0 " +
                         $"and d.TimeCodeId in ({txtRegCodeIds}) and e.id<>{currId ?? -1}";

            return((decimal)MobileCommon.ExecuteScalar(sql));
        }
        public List <EquipTimeEntry> GetSendList()       // must after sent headers
        {
            List <SyncCoreMatch> matchList = SyncCoreMatch.GetMatchList("LemHeader");
            string headerIds = StrEx.GetIdListText(matchList.Select(x => x.SourceId).ToList());

            string sql = $"select * from EquipTimeEntry where LogHeaderId in ({headerIds}) and (SyncStatus='{EnumRecordSyncStatus.NoSubmit}' or SyncStatus is null) and Deleted=0";

            DataTable             table = MobileCommon.ExecuteDataAdapter(sql);
            List <EquipTimeEntry> list  = table.Select().Select(r => new EquipTimeEntry(r)).ToList();

            list.ForEach(x => x.HeaderId = matchList.Single(m => m.SourceId == x.HeaderId).MatchId);

            return(list);
        }
Beispiel #16
0
        public static void SqlUpdateLemAP(int id, int?logHeaderId)
        {
            if (logHeaderId == null)
            {
                int matchId = (int)MobileCommon.ExecuteScalar($"select isnull(matchid, 0) from LemAP where id={id} and SyncStatus='{EnumRecordSyncStatus.Submitted}'");
                if (matchId != 0)
                {
                    DeleteHistory.SqlInsert(DeleteHistory.LemAPUnselect, matchId);
                }
            }

            string sql = $"update LemAP set LogHeaderId={StrEx.ValueOrNull(logHeaderId)}, SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id}";

            MobileCommon.ExecuteNonQuery(sql);
        }
Beispiel #17
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive()
        {
            try
            {
                Company.Refresh();

                using (HttpClient client = new HttpClient())
                {
                    client.Init();

                    HttpResponseMessage response = await client.GetAsync("api/Companies");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Company> list = await response.Content.ReadAsAsync <List <Company> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Company(MatchId, CompanyName, ShortName, Active, WeekStart, " +
                                         $"EquipRateGroupType, MaxLevelCode, Level1CodeDesc, Level2CodeDesc, Level3CodeDesc, Level4CodeDesc, " +
                                         $"CompanyAddress1, CompanyAddress2, CompanyAddress3, CompanyCity, CompanyState, CompanyZip, CompanyPhone, CompanyFax, " +
                                         $"CompanyEmail, CompanyWeb, InSync) " +
                                         $"values({x.MatchId}, '{StrEx.SqlEsc(x.CompanyName)}', '{x.ShortName}', '{x.Active}', {(Int16)x.WeekStart}, " +
                                         $"'{(char)x.EquipRateGroupType}', {x.MaxLevelCode}, '{x.Level1CodeDesc}', '{x.Level2CodeDesc}', '{x.Level3CodeDesc}', '{x.Level4CodeDesc}', " +
                                         $"'{StrEx.SqlEsc(x.CompanyAddress1)}', '{StrEx.SqlEsc(x.CompanyAddress2)}', '{StrEx.SqlEsc(x.CompanyAddress3)}', '{x.CompanyCity}', '{x.CompanyState}', " +
                                         $"'{x.CompanyZip}', '{x.CompanyPhone}', '{x.CompanyFax}', '{x.CompanyEmail}', '{x.CompanyWeb}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
Beispiel #18
0
        public List <LemAP> GetSendList()
        {
            new List <LemAP>();

            List <SyncCoreMatch> matchList = SyncCoreMatch.GetMatchList("LemHeader");
            string headerIds = StrEx.GetIdListText(matchList.Select(x => x.SourceId).ToList());

            string       sql   = $"select * from LemAP where companyId={CompanyId} and LogHeaderId in ({headerIds}) and (SyncStatus='{EnumRecordSyncStatus.NoSubmit}' or SyncStatus is null)";
            DataTable    table = MobileCommon.ExecuteDataAdapter(sql);
            List <LemAP> list  = table.Select().Select(r => new LemAP(r)).ToList();

            list.ForEach(x => x.HeaderId = matchList.Single(m => m.SourceId == x.HeaderId).MatchId);
            list.ForEach(x => x.GetDetailList());
            list.ForEach(x => x.DetailList.ForEach(d => d.LemAPId = x.MatchId));

            return(list);
        }
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    var query = HttpUtility.ParseQueryString(string.Empty);
                    query["companyId"] = CompanyId.ToString();
                    query["clientMac"] = MobileCommon.MachineMac;
                    query["contactId"] = LoginUser.CurrUser.MatchId.ToString();
                    HttpResponseMessage response = await client.GetAsync($"api/EquipTimeEntry?{query.ToString()}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        var list = await response.Content.ReadAsAsync <List <EquipTimeEntry> >();

                        list.ForEach(x =>
                        {
                            BeforeReceiveRecord(x.MatchId);
                            string sql = $"insert EquipTimeEntry(MatchID, CompanyId, LogHeaderId, EqpNum, ChangeOrderId, Level1Id, Level2Id, Level3Id, Level4Id, Billable, Quantity, BillCycle, BillAmount, SyncStatus, Deleted) " +
                                         $"values({x.MatchId}, {x.CompanyId}, {x.HeaderId}, '{x.EqpNum}', {StrEx.ValueOrNull(x.ChangeOrderId)}, {StrEx.ValueOrNull(x.Level1Id)}, {StrEx.ValueOrNull(x.Level2Id)}, " +
                                         $"{StrEx.ValueOrNull(x.Level3Id)}, {StrEx.ValueOrNull(x.Level4Id)}, '{x.Billable}', {x.Quantity}, '{(char)x.BillCycle}', {StrEx.ValueOrNull(x.BillAmount)}, '{EnumRecordSyncStatus.Receiving}', 0)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                ProjectLevelCode.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    var query = HttpUtility.ParseQueryString(string.Empty);
                    query["contactId"] = LoginUser.CurrUser.MatchId.ToString();
                    query["companyId"] = CompanyId.ToString();
                    HttpResponseMessage response = await client.GetAsync($"api/ProjectLevelCode?{query.ToString()}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <ProjectLevelCode> list = await response.Content.ReadAsAsync <List <ProjectLevelCode> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert ProjectLevelCode(ProjectId, CompanyId, Level1Id, Level2Id, Level3Id, Level4Id, InSync) " +
                                         $"values({x.ProjectId}, {x.CompanyId}, {StrEx.ValueOrNull(x.Level1Id)}, {StrEx.ValueOrNull(x.Level2Id)}, {StrEx.ValueOrNull(x.Level3Id)}, {StrEx.ValueOrNull(x.Level4Id)}, 1 )";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
    void showOneFile(ECLResInfor ri, bool canEdite, bool needFilter)
    {
        if (needFilter && searchKey != "")
        {
            if (!ri.path.ToLower().Contains(searchKey.ToLower()))
            {
                return;
            }
        }

        string fname = ri.relativePath;

        EditorGUILayout.BeginHorizontal();
        {
            if (canEdite)
            {
                bool selected = GUILayout.Toggle(ri.selected, "", GUILayout.Width(20));
                if (selected != ri.selected)
                {
                    ri.selected = selected;
                    if (ri.isDir)
                    {
                        ArrayList list = new ArrayList();
                        list.AddRange(datas);
                        int         count = list.Count;
                        ECLResInfor res   = null;
                        for (int i = 0; i < count; i++)
                        {
                            res = (ECLResInfor)(list [i]);
                            if (res.path.Contains(ri.path))
                            {
                                res.selected = selected;
                            }
                        }
                    }
                }
            }
            //			EditorGUILayout.LabelField ("", GUILayout.Width (ri.tabs * 4));
//		EditorGUILayout.SelectableLabel (StrEx.appendSpce ("v." + ri.ver, 6) + fname, GUILayout.Height (18));
            EditorGUILayout.SelectableLabel(StrEx.appendSpce("", 6) + fname, GUILayout.Height(18));
        }
        EditorGUILayout.EndHorizontal();
    }
Beispiel #22
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                OvertimeLimit.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/OvertimeLimits?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <OvertimeLimit> list = await response.Content.ReadAsAsync <List <OvertimeLimit> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert OvertimeLimit(MatchId, companyId, ProjectId, Code, [Desc], DailyLimit, DailyDoubleLimit, WeeklyLimit, WeeklyDoubleLimit, InSync) " +
                                         $"values({x.MatchId}, {x.CompanyId}, {StrEx.ValueOrNull(x.ProjectId)}, '{x.Code}', '{x.Desc}', {StrEx.ValueOrNull(x.DailyLimit)}, {StrEx.ValueOrNull(x.DailyDoubleLimit)}, " +
                                         $"{StrEx.ValueOrNull(x.WeeklyLimit)}, {StrEx.ValueOrNull(x.WeeklyDoubleLimit)}, 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                ProjectWorkClass.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/ProjectWorkClasses?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <ProjectWorkClass> list = await response.Content.ReadAsAsync <List <ProjectWorkClass> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert ProjectWorkClass(MatchId, CompanyId, ProjectId, WorkClassCode, RegularBillRate, OvertimeBillRate, DoubletimeBillRate, TravelBillRate, Schedulable, CeilingCost, RegularHours, TravelHours, InSync) " +
                                         $"values({x.MatchId}, {x.CompanyId}, {x.ProjectId}, '{x.WorkClassCode}', {StrEx.ValueOrNull(x.RegularBillRate)}, {StrEx.ValueOrNull(x.OvertimeBillRate)}, {StrEx.ValueOrNull(x.DoubleTimeBillRate)}, {StrEx.ValueOrNull(x.TravelBillRate)}," +
                                         $" '{x.Schedulable}', {StrEx.ValueOrNull(x.CeilingCost)}, {StrEx.ValueOrNull(x.RegularHours)}, {StrEx.ValueOrNull(x.TravelHours)}, 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                Employee.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/Employees?companyId={Company.CurrentId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Employee> list = await response.Content.ReadAsAsync <List <Employee> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Employee(EmpNum, CompanyId, FirstName, LastName, WorkClassCode, OvertimeCode, InSync) " +
                                         $"values({x.EmpNum}, {x.CompanyId}, '{StrEx.SqlEsc(x.FirstName)}', '{StrEx.SqlEsc(x.LastName)}', '{x.WorkClassCode}', '{x.OvertimeCode}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }

                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
Beispiel #25
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                Equipment.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/Equipments?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Equipment> list = await response.Content.ReadAsAsync <List <Equipment> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Equipment(EqpNum, CompanyId, AssetCode, [Desc], ClassCode, CategoryCode, OwnerType, InSync) " +
                                         $"values('{x.EqpNum}', {x.CompanyId}, '{StrEx.SqlEsc(x.AssetCode)}', '{StrEx.SqlEsc(x.Desc)}', '{StrEx.SqlEsc(x.ClassCode)}', '{StrEx.SqlEsc(x.CategoryCode)}', '{(char)x.OwnerType}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
Beispiel #26
0
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                EquipmentGroupBillRate.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/EquipmentGroupBillRates?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <EquipmentGroupBillRate> list = await response.Content.ReadAsAsync <List <EquipmentGroupBillRate> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert EquipmentGroupBillRate(CompanyId, ProjectId, GroupCode, GroupType, BillCycle, BillRate, IsDefault, InSync) " +
                                         $"values({x.CompanyId}, {StrEx.ValueOrNull(x.ProjectId)}, '{x.GroupCode}', '{(char)x.GroupType}', '{(char)x.BillCycle}', {x.BillRate}, '{x.IsDefault}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
Beispiel #27
0
 private void SetData(List <LemHeader> headerList)
 {
     tableHeader.Clear();
     headerList.Select(x => new { Header = x, project = Project.GetProject(x.ProjectId) }).ToList().ForEach(x =>
     {
         tableHeader.Rows.Add(
             x.Header.Id,
             x.Header.LogDate,
             x.Header.LemNum,
             x.Header.Description,
             (char)x.Header.LogStatus,
             GetEnumName(x.Header.SubmitStatus),
             x.Header.ProjectId,
             x.Header.ProjectId,
             x.Header.ApprovalComments,
             x.Header.EmailData != null,
             x.project?.CustomerCode,
             x.project?.CustomerName,
             x.project?.SiteLocation,
             StrEx.GetDateString(x.project?.StartDate),
             StrEx.GetDateString(x.project?.EstCompletionDate));
     });
     tableHeader.AcceptChanges();
 }
Beispiel #28
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                EquipmentTemplate.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/EquipmentTemplates?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <EquipmentTemplate> list = await response.Content.ReadAsAsync <List <EquipmentTemplate> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert EquipmentTemplate(MatchId, CompanyId, ProjectId, EqpNum, EquipClassCode, StartDate, EndDate, InSync) " +
                                         $"values({x.MatchId}, {x.CompanyId}, {x.ProjectId}, {x.EqpNum}, '{x.EquipClassCode}', {StrEx.StrOrNull(x.StartDate)}, {StrEx.StrOrNull(x.EndDate)}, 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                ChangeOrder.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/ChangeOrders?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <ChangeOrder> list = await response.Content.ReadAsAsync <List <ChangeOrder> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert ChangeOrder(CompanyId, ProjectId, EstimateId, ChangeOrderNum, ChangeOrderName, InSync) " +
                                         $"values({x.CompanyId}, {x.ProjectId}, {x.EstimateId}, {StrEx.ValueOrNull(x.ChangeOrderNum)}, '{x.ChangeOrderName}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
        public static void SqlUpdateBillRate(int entryId, int timecodeId, decimal?billRate)
        {
            string sql = $"update LabourTimeDetail set BillRate={StrEx.ValueOrNull(billRate)} where EntryId={entryId} and TimeCodeId={timecodeId}";

            MobileCommon.ExecuteNonQuery(sql);
        }