Example #1
0
        public List <Device> SelectDevicesByCrmUserId(string crmUserId)
        {
            var dataSet = CRMAccessDB.SelectQlabourdb(@"select * from devices where userid in (select id from AspNetUsers where CrmUserId = N'" + crmUserId + "')");


            List <Device> target = dataSet.Tables[0].AsEnumerable()
                                   .Select(row => new Device
            {
                Id       = row.Field <int>("Id"),
                DeviceId = row.Field <string>("DeviceId"),
                UserId   = row.Field <string>("UserId"),
                IsOnline = row.Field <bool>("IsOnline"),
            }).ToList();


            return(target);
        }
Example #2
0
        public List <Device> SelectAllDevices()
        {
            var dataSet = CRMAccessDB.SelectQlabourdb("select * from Devices");


            List <Device> target = dataSet.Tables[0].AsEnumerable()
                                   .Select(row => new Device
            {
                Id       = row.Field <int>("Id"),
                DeviceId = row.Field <string>("DeviceId"),
                UserId   = row.Field <string>("UserId"),
                IsOnline = row.Field <bool>("IsOnline"),
            }).ToList();


            return(target);
        }
Example #3
0
        //CRM Function that Connected to WorkFlow for creating Recieptvoucher with creating errors on transactions payment process with success transactions
        public string SendVouchersToCRM()
        {
            try
            {
                //1-Getting all RV that dident saved in CRM
                string    sql = @" select * from ReceiptVouchers where ReceiptVouchers.IsSaved=0";
                DataTable dt  = CRMAccessDB.SelectQlabourdb(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Entity Receipt = new Entity("new_receiptvoucher");
                        Receipt["new_contracthourid"]     = new EntityReference("new_hindvcontract", new Guid(dt.Rows[i]["ContractId"].ToString()));
                        Receipt["new_paymenttype"]        = new OptionSetValue(2);
                        Receipt["new_refrencenumber"]     = dt.Rows[i]["PaymentCode"].ToString();
                        Receipt["new_amount"]             = new Money(decimal.Parse(dt.Rows[i]["Amount"].ToString()));
                        Receipt["new_vaterate"]           = decimal.Parse(dt.Rows[i]["VatRate"].ToString());
                        Receipt["new_vatamount"]          = decimal.Parse(dt.Rows[i]["Amount"].ToString()) * decimal.Parse(dt.Rows[i]["VatRate"].ToString());
                        Receipt["new_totalamountwithvat"] = new Money((decimal.Parse(dt.Rows[i]["Amount"].ToString()) * decimal.Parse(dt.Rows[i]["VatRate"].ToString())) + decimal.Parse(dt.Rows[i]["Amount"].ToString()));
                        Receipt["new_receiptdate"]        = DateTime.Parse(dt.Rows[i]["Date"].ToString());
                        Receipt["new_contactid"]          = new EntityReference("contact", new Guid(dt.Rows[i]["CustomerId"].ToString()));
                        Receipt["new_pointofreciept"]     = new OptionSetValue(4);
                        Guid Id = GlobalCode.Service.Create(Receipt);
                        sql = @"update ReceiptVouchers set IsSaved=1 where Id=" + dt.Rows[i]["Id"].ToString();
                        CRMAccessDB.ExecuteNonQueryLaboursdb(sql);
                        Entity Contract = GlobalCode.Service.Retrieve("new_hindvcontract", new Guid(dt.Rows[i]["ContractId"].ToString()), new ColumnSet(false));
                        Contract["new_ispaid"]          = true;
                        Contract["new_contractconfirm"] = true;
                        Contract["statuscode"]          = new OptionSetValue(100000009);

                        GlobalCode.Service.Update(Contract);
                    }
                }
            }
            catch (Exception e)
            {
                return("ok");
            }

            return("ok");
        }
Example #4
0
        protected string Translate(string ResourceId, UserLanguage lang)
        {
            try
            {
                //1-Getting all RV that dident saved in CRM
                string    sql = String.Format(@" select [Value] FROM [LaborServices].[dbo].[Localizations]
                                                where [ResourceId] like '{0}' and [LocaleId] like '{1}'", ResourceId, (lang == UserLanguage.Arabic ? "ar" : "en"));
                DataTable dt  = CRMAccessDB.SelectQlabourdb(sql).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    return(dt.Rows[0]["Value"].ToString());
                }

                return(string.Empty);
            }
            catch (Exception e)
            {
                return(string.Empty);
            }
        }
Example #5
0
        internal string GetTermsForMobile(UserLanguage lang)
        {
            try
            {
                //1-Getting all RV that dident saved in CRM
                string    sql = @" select * FROM [LaborServices].[dbo].[Localizations]
  where [ResourceId] like 'TermsDataForMobile' and [LocaleId] like '" + (lang == UserLanguage.Arabic ? "ar" : "en") + "'";
                DataTable dt  = CRMAccessDB.SelectQlabourdb(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string terms = dt.Rows[i]["Value"].ToString();
                        return(terms);
                    }
                }
            }
            catch (Exception e)
            {
                return("");
            }

            return("");
        }