Exemple #1
0
 public int AccTestMethod(string param1)
 {
     using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
     {
         return(dbHelper.GetCount("afw.Acc", null));
     }
 }
Exemple #2
0
        public void DeleteCreatedActivity(string callID)
        {
            //DebugHelper.Break();
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                using (var tranManager = new DbTransactionManager(dbHelper))
                {
                    var receivedCallEntity = dbHelper.FetchSingle("cmn.ReceivedCall", string.Format("ID = '{0}'", callID), null);

                    if (receivedCallEntity.GetFieldValue <Guid?>("CreatedActivity") != null)
                    {
                        Guid activityID = receivedCallEntity.GetFieldValue <Guid>("CreatedActivity");

                        receivedCallEntity.SetFieldValue("SalesCase", null);
                        receivedCallEntity.SetFieldValue("DetectedCustomer", null);
                        receivedCallEntity.SetFieldValue("CreatedActivity", null);
                        receivedCallEntity.ChangeStatus = "Modify";

                        dbHelper.ApplyChanges(receivedCallEntity);

                        var activityEntity = dbHelper.FetchSingle("cmn.Activity", string.Format("ID = '{0}'", activityID), null);
                        if (activityEntity != null)
                        {
                            activityEntity.ChangeStatus = "Delete";
                            dbHelper.ApplyChanges(activityEntity);
                        }
                    }

                    tranManager.Commit();
                }
            }
        }
Exemple #3
0
        public int?GetAccountCodeMaxIntValue(string tableName, string parent, string year)
        {
            int?maxIntValue = null;

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                try
                {
                    string sqlQuery = string.Format(@"select isnull(max(cast(Code as int)), 0) MaxValue from {0}", tableName, parent, year);
                    if (!string.IsNullOrEmpty(parent))
                    {
                        sqlQuery += (" where parentAccount = '" + parent + "' ");
                    }
                    else if (parent == null)
                    {
                        sqlQuery += (" where parentAccount is null ");
                    }
                    if (!string.IsNullOrEmpty(year))
                    {
                        sqlQuery += (" and FinancialYear = '" + year + "' ");
                    }
                    else if (year == null)
                    {
                        sqlQuery += (" and FinancialYear is null");
                    }
                    maxIntValue = dbHelper.AdoDbHelper.ExecuteScalar <int?>(sqlQuery);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error in GetAccountCodeMaxIntValue.", ex);
                }
            }

            return(maxIntValue);
        }
Exemple #4
0
        public void SetRelatedContract(Guid receivedCallID, Guid contractId)
        {
            //DebugHelper.Break();

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                using (var tranManager = new DbTransactionManager(dbHelper))
                {
                    var receivedCallEntity = dbHelper.FetchSingle("cmn.ReceivedCall", string.Format("ID = '{0}'", receivedCallID), null);
                    var contractEntity     = dbHelper.FetchSingle("cmn.Contract", string.Format("ID = '{0}'", contractId), null);

                    if (receivedCallEntity.GetFieldValue <Guid?>("SalesCase") != null)
                    {
                        var salesCaseCustomerId = receivedCallEntity.GetFieldValue <Guid>("DetectedCustomer");
                        if (contractEntity.GetFieldValue <Guid>("Customer") != salesCaseCustomerId)
                        {
                            throw new AfwException("مشتری قرارداد با مشتری پرونده فروش متفاوت است.");
                        }
                    }
                    else
                    {
                        receivedCallEntity.SetFieldValue("DetectedCustomer", contractEntity.GetFieldValue <Guid>("Customer"));
                        receivedCallEntity.SetFieldValue("Contract", contractId);
                        dbHelper.ApplyChanges(receivedCallEntity);
                        receivedCallEntity.ChangeStatus = "Modify";
                        tranManager.Commit();
                    }
                }
            }
        }
Exemple #5
0
        public void SavePhoneNumberForPerson(string callID, string callNumber, string PersonID)
        {
            //DebugHelper.Break();
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                using (var tranManager = new DbTransactionManager(dbHelper))
                {
                    if (PersonID != null)
                    {
                        var phoneNumberEntity = dbHelper.CreateNewEntity("cmn.PhoneNumber");
                        var telTypeID         = OptionSetHelper.GetOptionSetItemID("cmn.PhoneType", "Unknown");

                        phoneNumberEntity.SetFieldValue("Person", PersonID);
                        phoneNumberEntity.SetFieldValue("Phone", callNumber);
                        phoneNumberEntity.SetFieldValue("Note", "تماس دریافتی");
                        phoneNumberEntity.SetFieldValue("TelType", telTypeID);

                        dbHelper.ApplyChanges(phoneNumberEntity);
                    }

                    var receivedCallEntity = dbHelper.FetchSingle("cmn.ReceivedCall", string.Format("ID = '{0}'", callID), null);
                    receivedCallEntity.SetFieldValue("CallPerson", PersonID);
                    receivedCallEntity.ChangeStatus = "Modify";

                    dbHelper.ApplyChanges(receivedCallEntity);

                    tranManager.Commit();
                }
            }
        }
Exemple #6
0
        public void SevePersonGroupAccounts(Guid accountID, Guid personGroupID, Guid financialYearID)
        {
            //DebugHelper.Break();  
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var kolLevelID = OptionSetHelper.GetOptionSetItemID("acc.AccountLevel", "Kol");
                var moinLevelID = OptionSetHelper.GetOptionSetItemID("acc.AccountLevel", "Moin");
                var tafsiliLevelID = OptionSetHelper.GetOptionSetItemID("acc.AccountLevel", "Tafsili");
                 
                var accountEntity = dbHelper.FetchSingle("acc.Account", string.Format("ID = '{0}'", accountID), null);

                if (accountEntity.GetFieldValue<Guid>("AccountLevel") == kolLevelID)
                {
                    var moinAccounts = dbHelper.FetchMultiple("acc.Account",
                        string.Format("ParentAccount = '{0}' and AccountLevel = '{1}'", accountID, moinLevelID), null, null, null, null);
                    if (moinAccounts.Entities.Count > 0)
                    {
                        for (var i = 0; i < moinAccounts.Entities.Count; i++)
                        {
                            var moinAccountID = moinAccounts.Entities[i].GetFieldValue<Guid>("ID");
                            var tafsiliAccounts = dbHelper.FetchMultiple("acc.Account",
                                string.Format("ParentAccount = '{0}' and AccountLevel = '{1}'", moinAccountID, tafsiliLevelID), null, null, null, null);
                            if (tafsiliAccounts.Entities.Count > 0)
                            {
                                for (var j = 0; j < tafsiliAccounts.Entities.Count; j++)
                                {
                                    var tafsiliAccountID = tafsiliAccounts.Entities[j].GetFieldValue<Guid>("ID");
                                    SevePersonGroupAccount(tafsiliAccountID, personGroupID, financialYearID);
                                }
                            }
                            else
                                SevePersonGroupAccount(moinAccountID, personGroupID, financialYearID);
                        }
                    }
                    else
                        SevePersonGroupAccount(accountID, personGroupID, financialYearID);
                }
                else if (accountEntity.GetFieldValue<Guid>("AccountLevel") == moinLevelID)
                {
                    var tafsiliAccounts = dbHelper.FetchMultiple("acc.Account",
                           string.Format("ParentAccount = '{0}' and AccountLevel = '{1}'", accountID, tafsiliLevelID), null, null, null, null);
                    if (tafsiliAccounts.Entities.Count > 0)
                    {
                        for (var j = 0; j < tafsiliAccounts.Entities.Count; j++)
                        {
                            var tafsiliAccountID = tafsiliAccounts.Entities[j].GetFieldValue<Guid>("ID");
                            SevePersonGroupAccount(tafsiliAccountID, personGroupID, financialYearID);
                        }
                    }
                    else
                        SevePersonGroupAccount(accountID, personGroupID, financialYearID);
                }
                else
                    SevePersonGroupAccount(accountID, personGroupID, financialYearID);
            }
        }
Exemple #7
0
        public void SetSalesCaseActivity(Guid receivedCallID, Guid activityID)
        {
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                using (var tranManager = new DbTransactionManager(dbHelper))
                {
                    //DebugHelper.Break();

                    var receivedCall = dbHelper.FetchSingle("cmn.ReceivedCall", string.Format("ID = '{0}'", receivedCallID), null);

                    if (receivedCall.GetFieldValue <Guid?>("CallPerson") == null)
                    {
                        throw new AfwException("امکان ست کردن فعالیت برای تماس دریافتی که شخص تماس گیرنده آن تعیین نشده وجود ندارد.");
                    }

                    var activity = dbHelper.FetchSingle("cmn.Activity", string.Format("ID = '{0}'", activityID), null);

                    var callPersonID = receivedCall.GetFieldValue <Guid>("CallPerson");
                    var salesCaseID  = activity.GetFieldValue <Guid>("SalesCase");

                    var salesCase = dbHelper.FetchSingle("crm.SalesCase", string.Format("ID = '{0}'", salesCaseID), null);

                    if (receivedCall.GetFieldValue <Guid?>("Contract") != null)
                    {
                        var contractCustomerId = receivedCall.GetFieldValue <Guid>("DetectedCustomer");
                        if (salesCase.GetFieldValue <Guid>("Customer") != contractCustomerId)
                        {
                            throw new AfwException("مشتری پرونده فروش با مشتری قرارداد متفاوت است.");
                        }
                    }

                    receivedCall.SetFieldValue("SalesCase", salesCaseID);
                    receivedCall.SetFieldValue("DetectedCustomer", salesCase.GetFieldValue <Guid>("Customer"));

                    receivedCall.SetFieldValue("CreatedActivity", activityID);
                    receivedCall.ChangeStatus = "Modify";
                    dbHelper.ApplyChanges(receivedCall);

                    if (callPersonID != salesCase.GetFieldValue <Guid>("Customer"))
                    {
                        if (!dbHelper.EntityExists("crm.SalesCaseConnectedPerson",
                                                   string.Format("SalesCase = '{0}' and ConnectedPerson = '{1}'", salesCaseID, callPersonID)))
                        {
                            var salesCaseConnectedPerson = dbHelper.CreateNewEntity("crm.SalesCaseConnectedPerson");
                            salesCaseConnectedPerson.SetFieldValue("SalesCase", salesCaseID);
                            salesCaseConnectedPerson.SetFieldValue("ConnectedPerson", callPersonID);

                            dbHelper.ApplyChanges(salesCaseConnectedPerson);
                        }
                    }

                    tranManager.Commit();
                }
            }
        }
Exemple #8
0
        public Entity GetNote(string id)
        {
            //DebugHelper.Break();

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var query = string.Format(@"select ID, CreationTime, Note from acc_PreDefinedNotes
                                            where ID = '{0}'", id);
                var note  = dbHelper.FetchSingleBySqlQuery(query);

                return(note);
            }
        }
 public void DeleteForeignCurrencyGroupAccount(Guid accountID, Guid foreignCurrencyGroupID)
 {
     //DebugHelper.Break();
     using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
     {
         var foreignCurrencyGroupAccountEntity = dbHelper.FetchSingle("acc.ForeignCurrencyGroupAccount",
                                                                      string.Format("Account = '{0}' and ForeignCurrencyGroup = '{1}'", accountID, foreignCurrencyGroupID), null);
         if (foreignCurrencyGroupAccountEntity != null)
         {
             dbHelper.DeleteEntity(foreignCurrencyGroupAccountEntity);
         }
     }
 }
Exemple #10
0
 public void DeleteProjectGroupAccount(Guid accountID, Guid projectGroupID)
 {
     //DebugHelper.Break();
     using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
     {
         var projectGroupAccountEntity = dbHelper.FetchSingle("acc.ProjectGroupAccount",
                                                              string.Format("Account = '{0}' and ProjectGroup = '{1}'", accountID, projectGroupID), null);
         if (projectGroupAccountEntity != null)
         {
             dbHelper.DeleteEntity(projectGroupAccountEntity);
         }
     }
 }
Exemple #11
0
        public EntityList GetKarteksTedadiRialiData(string fromDate, string toDate, Guid stuff, Guid person)
        {
            //DebugHelper.Break();

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var tempFromDate = fromDate.Split(' ');
                var tempToDate   = toDate.Split(' ');
                fromDate = tempFromDate[0].Replace('/', '-');
                toDate   = tempToDate[0].Replace('/', '-');
                var entityList = dbHelper.FetchMultipleBySqlQuery(string.Format(
                                                                      @"exec ps.KarteksTedadiRialiKala '{0}', '{1}', '{2}', '{3}'", fromDate, toDate, stuff, person));
                return(entityList);
            }
        }
Exemple #12
0
        public EntityList GetPersonRelatedSalesCases(Guid callPersonId)
        {
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                string strSQL = string.Format(@"
                    select SalesCase.ID, SalesCase.Customer   
                    from dbo.crm_SalesCases SalesCase     
                    where Customer = '{0}' 
                        or exists (select 1 from crm_SalesCaseConnectedPersons where ConnectedPerson = '{0}' and SalesCase = SalesCase.ID)", callPersonId);

                var salesCaseEntityList = dbHelper.FetchMultipleBySqlQuery(strSQL);

                return(salesCaseEntityList);
            }
        }
Exemple #13
0
        public void SeveProjectGroupAccount(Guid accountID, Guid projectGroupID, Guid financialYearID)
        {
            //DebugHelper.Break();
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var projectGroupAccountEntity = dbHelper.FetchSingle("acc.ProjectGroupAccount",
                                                                     string.Format("Account = '{0}' and ProjectGroup = '{1}'", accountID, projectGroupID), null);
                if (projectGroupAccountEntity == null)
                {
                    var projectGroupAccountNewEntity = dbHelper.CreateNewEntity("acc.ProjectGroupAccount");
                    projectGroupAccountNewEntity.SetFieldValue("Account", accountID);
                    projectGroupAccountNewEntity.SetFieldValue("ProjectGroup", projectGroupID);
                    projectGroupAccountNewEntity.ChangeStatus = "Add";

                    dbHelper.ApplyChanges(projectGroupAccountNewEntity);

                    var account       = projectGroupAccountNewEntity.GetFieldValue <Guid>("Account");
                    var floatPriority = dbHelper.FetchSingle("cmn.FloatPriority", string.Format("Account = '{0}' and FinancialYear = '{1}'", account, financialYearID), null);
                    if (floatPriority == null)
                    {
                        floatPriority = dbHelper.CreateNewEntity("cmn.FloatPriority");
                        floatPriority.SetFieldValue("Account", account);
                        floatPriority.SetFieldValue("PersonPriority", 0);
                        floatPriority.SetFieldValue("CostCenterPriority", 0);
                        floatPriority.SetFieldValue("ProjectPriority", 1);
                        floatPriority.SetFieldValue("ForeignCurrencyPriority", 0);
                        floatPriority.SetFieldValue("FinancialYear", financialYearID);

                        dbHelper.ApplyChanges(floatPriority);
                    }
                    else
                    {
                        if (floatPriority.GetFieldValue <int>("ProjectPriority") == 0)
                        {
                            floatPriority.ChangeStatus = "Modify";

                            int maxPriority = cmn.Instance.GetPrioriryMaxValue(account, financialYearID);

                            floatPriority.SetFieldValue("ProjectPriority", maxPriority + 1);

                            dbHelper.ApplyChanges(floatPriority);
                        }
                    }
                }
            }
        }
Exemple #14
0
        public EntityList GetPersonRelatedContracts(Guid personId)
        {
            //DebugHelper.Break();
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                string sqlStr = string.Format(@"
                    select Cntrct.ID, Cntrct.Customer 
                    from cmn_Contracts Cntrct
                        inner join afw_OptionSetItems ContractStatus on ContractStatus.ID = Cntrct.Status 
                    where ContractStatus.Name = 'Active' and (Cntrct.Customer = '{0}' or 
                        exists (select 1 from cmn_PersonMembers where MemberPerson = '{0}' and ParentPerson = Cntrct.Customer))", personId);

                var contractEntityList = dbHelper.FetchMultipleBySqlQuery(sqlStr);

                return(contractEntityList);
            }
        }
Exemple #15
0
        public string GenerateStuffDefName(Guid stuffDefId)
        {
            string title = "";

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                string strSQL = string.Format(@"
                    select MainCategory.Title  + ' ' + SubCategory.Title + ' ' + StuffDef.Name
                    from cmn_StuffDefs StuffDef 
                        inner join cmn_StuffSubCategories SubCategory on SubCategory.ID = StuffDef.SubCategory 
                        inner join cmn_StuffMainCategories MainCategory on MainCategory.ID = SubCategory.MainCategory 
                    where StuffDef.ID = '{0}' ", stuffDefId);

                title = dbHelper.AdoDbHelper.ExecuteScalar(strSQL).ToString();
            }

            return(title);
        }
Exemple #16
0
        public void OnDataListEntityCountRequested(Entity dataList, string[] parameterNames, string[] parameterValues, string filterExpression, ref int?entityCount)
        {
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                if (parameterNames != null)
                {
                    //var financialGroup = parameterValues[3] == "" ? "null" : "'" + parameterValues[3] + "'";
                    //var person = string.IsNullOrEmpty(parameterValues[4])? "null" : string.Format("'{0}'", parameterValues[4]);
                    //var financialYear = parameterValues[3];
                    var financialGroup = parameterValues[3];
                    var person         = parameterValues[4];
                    var invoiceType    = parameterValues[5];

                    financialGroup = string.IsNullOrEmpty(financialGroup) ? "null" :
                                     string.Format("N'{0}'", financialGroup.Replace("'", "''"));

                    filterExpression = string.IsNullOrEmpty(filterExpression) ? "null" :
                                       string.Format("N'{0}'", filterExpression.Replace("'", "''"));

                    person = string.IsNullOrEmpty(person) ? "null" :
                             string.Format("N'{0}'", person.Replace("'", "''"));

                    var query = string.Format("exec ps.GetSalesAndBuyInvoices '{0}', '{1}', '{2}', {3}, {4}, {5}, {6}, {7}, {8}, {9}",
                                              parameterValues[0], parameterValues[1], parameterValues[2], financialGroup,
                                              person, invoiceType == null ? "null" : invoiceType, filterExpression, "null", "null", "null");

                    var resultEntity = dbHelper.FetchMultipleBySqlQuery(query);

                    if (resultEntity.Entities.Count > 0)
                    {
                        entityCount = resultEntity.Entities[0].GetFieldValue <int>("TotalRecordsCount");
                    }
                    else
                    {
                        entityCount = 0;
                    }
                    //var resultEntity = dbHelper.AdoDbHelper.ExecuteScalar(query);

                    //entityCount = (int)resultEntity;
                }
            }
        }
Exemple #17
0
        public EntityList GetProjectGroupAccounts(Guid projectGroupID, Guid financialYearID)
        {
            //DebugHelper.Break();

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var projectGroupAccounts = dbHelper.FetchMultipleBySqlQuery(string.Format(@"
                    select ProjectGroupAcc.ID, ProjectGroupAcc.Account, ProjectGroupAcc.ProjectGroup,
                        coalesce(PPAccount.Code + ' - ', '') + coalesce(PAccount.Code + ' - ', '') + isnull(Account.Code, '') Code,
                        coalesce(PPAccount.Name + ' - ', '') + coalesce(PAccount.Name + ' - ', '') + isnull(Account.Name, '') Name
                    from acc_ProjectGroupAccounts ProjectGroupAcc
                        inner join acc_Accounts Account on Account.ID = ProjectGroupAcc.Account
                        inner join cmn_ProjectGroups ProjectGroup on ProjectGroup.ID = ProjectGroupAcc.ProjectGroup 
                        left join acc_Accounts PAccount on PAccount.ID = Account.ParentAccount
                        left join acc_Accounts PPAccount on PPAccount.ID = PAccount.ParentAccount 
                    where ProjectGroupAcc.ProjectGroup = '{0}' and Account.FinancialYear = '{1}'", projectGroupID, financialYearID));

                return(projectGroupAccounts);
            }
        }
Exemple #18
0
        //internal void OnEntityListOfDataListRequested(Entity dataList, string[] parameterNames, object[] parameterValues, string filterExpression, string sortExpression, int? startRecord, int? maxRecords,
        //    ref EntityList resultEntityList)
        //{

        //}

        public void OnEntityListOfDataListRequested(Entity dataList, string[] parameterNames, string[] parameterValues, string filterExpression, string sortExpression, int?startRecord, int?maxRecords, ref EntityList resultEntityList)
        {
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var invoiceType = parameterValues[5];

                var financialGroup = parameterValues[3] == "" ? "null" : "'" + parameterValues[3] + "'";
                var person         = parameterValues[4] == "" ? "null" : "'" + parameterValues[4] + "'";

                filterExpression = string.IsNullOrEmpty(filterExpression) ? "null" :
                                   string.Format("N'{0}'", filterExpression.Replace("'", "''"));

                sortExpression = string.IsNullOrEmpty(sortExpression) ? "null" : "'" + sortExpression + "'";

                var query = string.Format("exec ps.GetSalesAndBuyInvoices '{0}','{1}','{2}',{3} ,{4} ,{5} ,{6} ,{7} ,{8} , {9}",
                                          parameterValues[0], parameterValues[1], parameterValues[2], financialGroup,
                                          person, invoiceType == null ? "null" : invoiceType, filterExpression, sortExpression, startRecord, maxRecords);

                resultEntityList = dbHelper.FetchMultipleBySqlQuery(query);
            }
        }
Exemple #19
0
        public void DetectUndetectedCalls(string filterExpression, string sortExpression, int?startRecordNumber, int?pageSize)
        {
            //DebugHelper.Break();

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                using (var tranManager = new DbTransactionManager(dbHelper))
                {
                    var receivedCallsEntityList = dbHelper.FetchMultiple("cmn.ReceivedCall", filterExpression.Replace("Gregorian", ""), sortExpression, startRecordNumber, pageSize, null);

                    foreach (Entity receivedCall in receivedCallsEntityList.Entities)
                    {
                        if (receivedCall.GetFieldValue <Guid?>("CallPerson") == null)
                        {
                            DetectCallPerson(receivedCall);
                        }
                    }

                    tranManager.Commit();
                }
            }
        }
Exemple #20
0
        public Entity GetSeasonalPurchaseAndSalesReportFormTotalAmounts(string dataListControlFilterExpression)
        {
            var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper();

            var dataListControlSqlQueryText = dbHelper.FetchSingleBySqlQuery(@"
                select * 
                from afw_DataListsView 
                where FullName = 'ps.SeasonalPurchaseAndSalesReports'");

            var sqlQuery = string.Format(@"
                select sum(TotalStuffAndServicesPrice) TotalStuffAndServicesPriceSum,
	                sum(TotalTaxAndToll) TotalTaxAndTollSum,
	                sum(Discount) DiscountSum,
	                sum(StuffAndServicesTotalAmountAfterDiscount) StuffAndServicesTotalAmountAfterDiscountSum,
	                sum(FinalAmount) FinalAmountSum
                from ({0}) SubQuery
                where {1}", dataListControlSqlQueryText.GetFieldValue <string>("SqlQueryText"), dataListControlFilterExpression);

            var resultEntity = dbHelper.FetchSingleBySqlQuery(sqlQuery);

            return(resultEntity);
        }
Exemple #21
0
        public void DeletePersonGroupAccount(Guid accountID, Guid personGroupID/*, Guid financialYearID*/)
        {
            //DebugHelper.Break();  
            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var personGroupAccountEntity = dbHelper.FetchSingle("acc.PersonGroupAccount",
                    string.Format("Account = '{0}' and PersonGroup = '{1}'", accountID, personGroupID), null);
                if (personGroupAccountEntity != null)
                    dbHelper.DeleteEntity(personGroupAccountEntity);

                //var floatPriority = dbHelper.FetchSingle("cmn.FloatPriority", string.Format("Account = '{0}' and FinancialYear = '{1}'", accountID, financialYearID), null);
                //if (floatPriority != null)
                //{  
                //    floatPriority.SetFieldValue("PersonPriority", 0);

                //    floatPriority.SetFieldValue("CostCenterPriority", 0);
                //    floatPriority.SetFieldValue("ProjectPriority", 0);
                //    floatPriority.SetFieldValue("ForeignCurrencyPriority", 0); 

                //    dbHelper.ApplyChanges(floatPriority);
                //}
            } 
        }
Exemple #22
0
        public int?GetServicePrice(Guid serviceID)
        {
            //DebugHelper.Break();

            int?UnitPrice = null;

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                try
                {
                    UnitPrice = dbHelper.AdoDbHelper.ExecuteScalar <int?>(string.Format(
                                                                              @"select PriceListItem.UnitPrice
                      from ps_PriceListServiceItems PriceListItem
                        inner join ps_PriceLists PriceList on PriceList.ID = PriceListItem.PriceList
                        inner join cmn_Services Servic on Servic.ID = PriceListItem.Service
                      where PriceList.IsActive = 1 and Servic.ID = '{0}'", serviceID));
                }
                catch (Exception ex)
                {
                    throw new Exception("Error in GetServicePrice.", ex);
                }
            }
            return(UnitPrice);
        }
Exemple #23
0
        public EntityList GetSalesAndBuyInvoices(string fromDate, string toDate, Guid financialYear, string financialGroup, string person)
        {
            //DebugHelper.Break();

            using (var dbHelper = DbHelperFactory.CreateMainDbEntityDbHelper())
            {
                var tempFromDate = fromDate.Split(' ');
                var tempToDate   = toDate.Split(' ');
                fromDate = tempFromDate[0].Replace('/', '-');
                toDate   = tempToDate[0].Replace('/', '-');


                financialGroup = financialGroup == null ? "null" : "'" + financialGroup + "'";
                person         = person == null ? "null" : "'" + person + "'";

                var entityList = dbHelper.FetchMultipleBySqlQuery(string.Format(
                                                                      @"exec ps.GetSalesAndBuyInvoices '{0}', '{1}', '{2}', {3}, {4}", fromDate, toDate, financialYear,
                                                                      financialGroup, person));

                ps.SalesAndBuyInvoices = entityList;

                return(entityList);
            }
        }