Пример #1
0
        public ActionResult AddBudget(SearchModel search)
        {
            ViewBag.Terms = Terms(false, false, false);

            ViewBag.Services = Services(null, false);

            BudgetModel budgget = new BudgetModel();

            budgget.CompanyId = search.CompanyId;
            budgget.CompanyName = search.CompanyName;
            budgget.AX = search.AX;
            budgget.IsActive = search.IsActive;

            budgget.DisplayName = search.DisplayName;
            budgget.ContactPerson = search.ContactPerson;
            budgget.CompanyHandle = search.CompanyHandle;

            //Session["CompanyId"] = budgget.CompanyId;
            //Session["CompanyName"] = budgget.CompanyName;
            //Session["Ax"] = budgget.AX;
            //Session["IsActive"] = budgget.IsActive;
            //Session["DisplayName"] = budgget.DisplayName;
            //Session["ContactPerson"] = budgget.ContactPerson;
            //Session["CompanyHandle"] = budgget.CompanyHandle;

            return View(budgget);
        }
Пример #2
0
        public static IEnumerable<BudgetModel> SearchCompany(SearchModel search)
        {
            //if (search.CompanyId)
            //{
            //    search.CompanyId = search.CompanyId.Trim();
            //}
            if (!string.IsNullOrEmpty(search.CompanyName))
            {
                search.CompanyName = search.CompanyName.Trim();
            }

            if (!string.IsNullOrEmpty(search.AX))
            {
                search.AX = search.AX.Trim();
            }
             if (!string.IsNullOrEmpty(search.InsertionOrderId))
            {
                search.InsertionOrderId = search.InsertionOrderId.Trim();
            }
            return DataLayer.SearchCompany(search);
        }
Пример #3
0
        public static IEnumerable<BudgetModel> SearchCompany(SearchModel search)
        {
            List<BudgetModel> list = new List<BudgetModel>();
            using (SqlConnection dbCon = ConnectToDb(DBConnString))
            {
                SqlCommand cmdGetCompany = new SqlCommand();
                cmdGetCompany.Connection = dbCon;
                cmdGetCompany.CommandType = System.Data.CommandType.StoredProcedure;
                //cmdGetCompany.CommandText = "usp_GetCompanyDetails";
                cmdGetCompany.CommandText = "usp_companySearchv3";

                SqlParameter paramCompanyId = new SqlParameter("companyID", search.CompanyId);
                SqlParameter paramCompanyName = new SqlParameter("companyName", search.CompanyName);
                //SqlParameter paramAreacode = new SqlParameter("areaCode", search.AreaCodes);
                //SqlParameter paramAgreement = new SqlParameter("agreement", search.AgreementNumber);
                SqlParameter paramAx = new SqlParameter("ax", search.AX);
                SqlParameter paramInsertion = new SqlParameter("insertionOrderId", search.InsertionOrderId);

                cmdGetCompany.Parameters.Add(paramCompanyId);
                cmdGetCompany.Parameters.Add(paramCompanyName);
                //cmdGetCompany.Parameters.Add(paramAreacode);
               // cmdGetCompany.Parameters.Add(paramAgreement);
                cmdGetCompany.Parameters.Add(paramAx);
                cmdGetCompany.Parameters.Add(paramInsertion);

                DataTable dtResults = new DataTable();

                SqlDataReader drResults = cmdGetCompany.ExecuteReader();
                dtResults.Load(drResults);

                foreach (DataRow row in dtResults.Rows)
                {
                     int? cid = 0;

                     if (!string.IsNullOrEmpty(row["CompanyID"].ToString()))
                     {
                         cid = Convert.ToInt32(row["CompanyID"]);
                     }
                    BudgetModel s = new BudgetModel {
                      //  CompanyId = row[""],

                        CompanyId = cid,
                        CompanyName = row["companyName"].ToString(),
                        AX = row["AbNumber"].ToString(),
                        InsertionOrderId = row["insertionOrderId"].ToString(),
                        DisplayName = row["displayName"].ToString(),
                        CompanyHandle = row["companyHandle"].ToString(),
                        ContactPerson = row["contactPerson"].ToString()
                        //AgreementNumber = row["agreementNumber"].ToString(),
                       // AreaCodes = row["Area Code"].ToString()

                    };
                    list.Add(s);
                }

                return list;
            }
        }
Пример #4
0
        public ActionResult Search(SearchModel search)
        {
            try
            {
                if (search.CompanyId == null && search.CompanyName == null && search.InsertionOrderId == null && search.AX == null)
                {
                    return View(search);
                }

                var budget = BusinessLayer.SearchCompany(search);
                search.budget = budget;
                if (budget.Count() > 0)
                {
                    foreach (var b in budget)
                    {
                        Session["CompanyId"] = b.CompanyId;
                        Session["CompanyName"] = b.CompanyName;
                        Session["Ax"] = b.AX;
                        Session["IsActive"] = b.IsActive;
                        Session["DisplayName"] = b.DisplayName;
                        Session["ContactPerson"] = b.ContactPerson;
                        Session["CompanyHandle"] = b.CompanyHandle;
                        break;
                    }

                }

                return View(search);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            return View(search);
        }
Пример #5
0
        public ActionResult GetBudget(string companyid, string companyName, string ax, string displayname, string contactperson, string companyHandle)
        {
            // MoversEntities dc = new MoversEntities();
            IEnumerable<BudgetModel> budgetList = new List<BudgetModel>();
            SearchModel search = new SearchModel();
            var cmpid = Convert.ToInt32(companyid);
            budgetList = BusinessLayer.GetBudget(companyid);

            var tbilled = budgetList.Where(b => b.EndDate < DateTime.Now).Sum(b => b.TotalBudget);
            var uamount = budgetList.Where(b => b.EndDate < DateTime.Now).Sum(b => b.UnchargedAmount);

            ViewBag.TotalBilled = String.Format("{0:C}", tbilled);
            ViewBag.UnchargedAmount = String.Format("{0:C}", uamount);

            search.CompanyId = cmpid;
            search.AX = ax;
            search.CompanyName = companyName;
            search.budget = budgetList;
            search.ContactPerson = contactperson;
            search.DisplayName = displayname;
            search.CompanyHandle = companyHandle;
            return View(search);
        }