コード例 #1
0
        public void AddUserDevice(string userId, string deviceId)
        {
            int affectedRows = CRMAccessDB.ExecuteNonQueryLaboursdb(@"declare @countId INT 
set @countId = (select count([Id]) from [Devices] where [DeviceId] = N'" + deviceId + @"')
if @countId = 0 
begin

INSERT INTO [dbo].[Devices]
           ([DeviceId]
           ,[UserId]
           ,[IsOnline])
     VALUES
           (N'" + deviceId + @"'
           ,N'" + userId + @"'
           ,N'0')
end");
        }
コード例 #2
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");
        }