Summary description for DbServices
Exemple #1
0
    public ActualTask GetTask()
    {
        #region DB functions
        string query = "select at.id, at.title, at.description, at.end_date, at.assign_to, e.first_name from actual_tasks at inner join employees e on at.assign_to = e.id where at.id =" + Id + "";

        ActualTask task = new ActualTask();
        DbServices db   = new DbServices();
        DataSet    ds   = db.GetDataSetByQuery(query);

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            try
            {
                Employee emp = new Employee();

                task.Id          = (int)dr["id"];
                task.Title       = dr["title"].ToString();
                task.Description = dr["description"].ToString();
                task.End_date    = (DateTime)dr["end_date"];
                emp.First_name   = dr["first_name"].ToString();
                emp.Id           = (int)dr["assign_to"];
                task.Assign_to   = emp;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw ex;
            }
        }
        #endregion

        return(task);
    }
Exemple #2
0
    public string Inventory()
    {
        List <Inventory> list   = DbServices.GetIventory();
        string           output = new JavaScriptSerializer().Serialize(list);

        return(output);
    }
Exemple #3
0
    public List <Project> GetProjectsList(int id)
    {
        DbServices dbs            = new DbServices();
        Employee   emp            = new Employee();
        DataTable  employeesTable = emp.getEmployeesTable();
        DataTable  projectsTable  = dbs.getFullTable("projects");

        var results = (from p
                       in projectsTable.AsEnumerable()
                       join pm in employeesTable.AsEnumerable()
                       on p.Field <int>("project_manager") equals pm.Field <int>("id")
                       join cb in employeesTable.AsEnumerable()
                       on p.Field <int>("created_by") equals cb.Field <int>("id")
                       where p.Field <int>("id") == id
                       select new Project
        {
            Title = p["title"].ToString(),
            Start_date = (DateTime)p["start_date"],
            Contact_name = p["contact_name"].ToString(),
            Description = p["description"].ToString(),
            End_date = (DateTime)p["end_date"],
            Id = Convert.ToInt32(p["id"]),
            Priority_key = p["priority_key"].ToString(),
            Contact_phone = Convert.ToInt32(p["contact_phone"]),
            Created_by = emp.GetEmployee(cb),
            Project_manager = emp.GetEmployee(pm)
        });

        return(results.ToList());;
    }
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as CallbackQueryEventArgs).CallbackQuery.Data;
            Chat   chat      = (e as CallbackQueryEventArgs).CallbackQuery.Message.Chat;

            if (!Validator.CheckNumber(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadNumber);

                return;
            }

            long          roomTypeId = int.Parse(userInput);
            HotelRoomType roomType   = ServicesHotelRoomType.GetHotelRoomTypeById(roomTypeId);
            List <string> photos     = DbServices.GetHotelRoomTypeImagesUrl(roomTypeId);

            if (roomType == null)
            {
                await ServicesMessageController.SendMessageAsync(
                    chat, "Такого типу номеру не існує", Keyboards.ReturnMainMenu);

                return;
            }

            string message = ViewRoomType.GetTextAboutRoomType(roomType);
            await ServicesMessageController.SendPhotosAsync(chat.Id, photos);

            await ServicesMessageController.SendMessageAsync(chat, message, Keyboards.ReturnMainMenu);

            responder.SetState(new HotelRoom_0());
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.ActionDescriptor.IsDefined(typeof(ExemptionInjectionAttribute), false) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(ExemptionInjectionAttribute), false))
            {
                return;
            }
            var viewModel = new SysSetVM();

            if (!CacheManager.Contains(Keys.SysSetCacheKey))
            {
                using (var services = new DbServices())
                {
                    services.Command((db) =>
                    {
                        Mapper.Initialize(c => c.CreateMap <SysSet, SysSetVM>());
                        viewModel = Mapper.Map <SysSetVM>(db.Queryable <SysSet>().FirstOrDefault());
                    });
                }
                CacheManager.Set(Keys.SysSetCacheKey, viewModel);
            }
            else
            {
                viewModel = CacheManager.Get <SysSetVM>(Keys.SysSetCacheKey);
            }
            if (filterContext.RouteData.DataTokens[Keys.SysSetInfoInjectionKey] == null)
            {
                filterContext.RouteData.DataTokens.Add(Keys.SysSetInfoInjectionKey, viewModel);
            }
        }
Exemple #6
0
    public string GetCart(int userid)
    {
        List <Item> list   = DbServices.GetCart(userid);
        string      output = new JavaScriptSerializer().Serialize(list);

        return(output);
    }
    Wiki.Page Save()
    {
        // Get the slashes correct and trim it
        txtPath.Text = txtPath.Text.Replace('\\', '/').Trim();
        // Ensure they start with a slash
        if (!txtPath.Text.StartsWith("/"))
        {
            txtPath.Text = "/" + txtPath.Text;
        }

        // Ensure its a unique name
        String path       = txtPath.Text;
        string newurlpath = Wiki.Page.PathToUrlPath(path);

        // Are they renaming it? If so, check for dupes
        if (urlpath.ToLower() != newurlpath.ToLower())
        {
            int uniqCount = 2;
            while (DbServices.PageExistsWithUrlpath(newurlpath))
            {
                path       = txtPath.Text + " " + uniqCount.ToString();
                newurlpath = Wiki.Page.PathToUrlPath(path);
                uniqCount++;
            }
        }

        Wiki.Page page = DbServices.FindPageByUrlpath(urlpath);
        page.path     = path;
        page.contents = txtRichEditor.Text.Trim();
        page.author   = Auth.UserName;
        page.Save();

        return(page);
    }
Exemple #8
0
    public string ISdiscount()
    {
        List <Item> list   = DbServices.ISdiscount();
        string      output = new JavaScriptSerializer().Serialize(list);

        return(output);
    }
Exemple #9
0
    public List <Employee> GetAssignToList()
    {
        #region DB functions
        string query = "select e.id emp_id, e.first_name from employees as e";

        List <Employee> AssignToList = new List <Employee>();
        DbServices      db           = new DbServices();
        DataSet         ds           = db.GetDataSetByQuery(query);

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            try
            {
                Employee assign_to = new Employee();

                assign_to.Id         = (int)dr["emp_id"];
                assign_to.First_name = dr["first_name"].ToString();

                AssignToList.Add(assign_to);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw ex;
            }
        }
        #endregion

        return(AssignToList);
    }
Exemple #10
0
    public string Favorites(int userid)
    {
        List <Inventory> list   = DbServices.Favorites(userid);
        string           output = new JavaScriptSerializer().Serialize(list);

        return(output);
    }
Exemple #11
0
    public DataTable getEmployeesTable()
    {
        DbServices dbs            = new DbServices();
        DataTable  employeesTable = dbs.getFullTable("employees");

        return(employeesTable);
    }
        public override async void ReceiveMessageAsync(EventArgs e)
        {
            string userInput = (e as CallbackQueryEventArgs).CallbackQuery.Data;
            Chat   chat      = (e as CallbackQueryEventArgs).CallbackQuery.Message.Chat;

            if (!Validator.CheckNumber(userInput))
            {
                await ServicesMessageController.SendMessageAsync(chat, Validator.BadNumber);

                return;
            }
            long id            = long.Parse(userInput);
            var  listRoomTypes = DbServices.GetAviableRoomTypes(arrival, departure, int.Parse(adults), int.Parse(children));

            if (ServicesHotelRoomType.GetHotelRoomTypeById(id) == null ||
                !listRoomTypes.Exists(t => t.Id == id))
            {
                await ServicesMessageController.SendMessageAsync(
                    chat, "Оберіть тип номеру", Keyboards.ReturnMainMenu);

                return;
            }
            ;

            responder.userTempData["HotelRoomTypeId"] = userInput;
            responder.SetState(new BookRoom_05());
        }
Exemple #13
0
    public Request GetRequest()
    {
        #region DB functions
        string query = "select r.id, r.title, r.description, r.contact_name, r.contact_phone, r.assign_to, e.first_name from requests r inner join employees e on r.assign_to = e.id where r.id =" + Id + "";

        Request    req = new Request();
        DbServices db  = new DbServices();
        DataSet    ds  = db.GetDataSetByQuery(query);

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            try
            {
                Employee emp = new Employee();

                req.Id            = (int)dr["id"];
                req.Title         = dr["title"].ToString();
                req.Description   = dr["description"].ToString();
                req.Contact_name  = dr["contact_name"].ToString();
                req.Contact_phone = (int)dr["contact_phone"];
                emp.First_name    = dr["first_name"].ToString();
                emp.Id            = (int)dr["assign_to"];
                req.Assign_to     = emp;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw ex;
            }
        }
        #endregion

        return(req);
    }
Exemple #14
0
    protected void bnSave_Click(object sender, EventArgs e)
    {
        // Get the slashes correct and trim it
        txtPath.Text = txtPath.Text.Replace('\\', '/').Trim();
        // Ensure they start with a slash
        if (!txtPath.Text.StartsWith("/"))
        {
            txtPath.Text = "/" + txtPath.Text;
        }

        // Ensure its a unique name
        String path      = txtPath.Text;
        string urlpath   = Wiki.Page.PathToUrlPath(path);
        int    uniqCount = 2;

        while (DbServices.PageExistsWithUrlpath(urlpath))
        {
            path    = txtPath.Text + " " + uniqCount.ToString();
            urlpath = Wiki.Page.PathToUrlPath(path);
            uniqCount++;
        }

        // Save it
        Wiki.Page page = new Wiki.Page();
        page.path     = path;
        page.contents = txtRichEditor.Text.Trim();
        page.author   = Auth.UserName;
        page.Save();
        Response.Redirect("./?" + page.urlpath);
    }
        public void StartLog(ErrorLog logger)
        {
            using (var services = new DbServices())
            {
                services.Command((db) =>
                {
                    db.Insert <ErrorLog>(logger);
                });
            }

            MailHelper.SendTextEmail("百签软件有限公司 技术支持", "*****@*****.**", "百小僧", "*****@*****.**", "应用程序异常通知",
                                     @"<p>引起异常会员ID:" + logger.LogMemberID + @"</p>

            <p>引起异常会员账号:" + logger.Account + @"</p>

            <p>当前异常应用程序:" + logger.Source + @"</p>

            <p>引起异常链接地址:" + logger.ErrorUrl + @"</p>

            <p>异常消息:" + logger.Message + @"</p>

            <p>引起异常的方法:" + logger.TargetSite + @"</p>

            <p>异常堆栈信息:<pre>" + logger.StackTrace + @"</pre></p>

            <p>异常编码数字:" + logger.HResult + @"</p>

            <p>异常帮助文档:" + logger.HelpLink + @"</p>

            <p>异常记录时间:" + logger.LogTime + @"</p>

            <p style='text-align:right;'><br /><br />来至:<a title='百签软件(中山)有限公司' href='http://www.baisoft.org/'>百签软件(中山)有限公司</a> 异常监控

           <br />" + DateTime.Now + @"</p>");
        }
Exemple #16
0
    public string Login(string userName, int pass)
    {
        User user = DbServices.Login(userName, pass);

        string output = new JavaScriptSerializer().Serialize(user);

        return(output);
    }
 public override async void OnStateChange(Chat chat)
 {
     DateTime      firstDate  = DateTime.Now.AddDays(1);
     DateTime      secondDate = firstDate.AddDays(6);
     List <string> dates      = DbServices.GetIntermediateDates(firstDate, secondDate);
     await ServicesMessageController.SendMessageAsync(
         chat, "Введіть дату прибуття", Keyboards.NextDates(dates));
 }
Exemple #18
0
 public override async void OnStateChange(Chat chat)
 {
     responder.userTempData.TryGetValue("DateOfArrival", out string firstDateString);
     DateTime      firstDate  = DateTime.Parse(firstDateString).AddDays(1);
     DateTime      secondDate = firstDate.AddDays(6);
     List <string> dates      = DbServices.GetIntermediateDates(firstDate, secondDate);
     await ServicesMessageController.SendMessageAsync(
         chat, "Введіть дату відбуття", Keyboards.NextDates(dates));
 }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(Nullable <int> product)
        {
            if (product == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LoanVwViewModel loanVwViewModel = new LoanVwViewModel();

            Db db = new Db(DbServices.ConnectionString);

            // loanVwViewModel.Instance = LoanVwServices.Get(product.Value, db);
            loanVwViewModel.Instance = LoanVwServices.GetChildren(product.Value, db);
            if (loanVwViewModel.Instance == null)
            {
                return(HttpNotFound());
            }


            @ViewBag.IncomingLoanVwTitle = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "IncomingLoan", "ModuleName");
            if (loanVwViewModel.Instance.IncomingLoanVw != null)
            {
                loanVwViewModel.IncomingLoanVwViewModel.List.Add(loanVwViewModel.Instance.IncomingLoanVw);
            }
            // loanVwViewModel.IncomingLoanVwViewModel.Instance = loanVwViewModel.Instance.IncomingLoanVw;

            @ViewBag.LoanChangeVwTitle = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "LoanChange", "ModuleName");
            if (loanVwViewModel.Instance.LoanChangeVw != null)
            {
                loanVwViewModel.LoanChangeVwViewModel.List.Add(loanVwViewModel.Instance.LoanChangeVw);
            }
            // loanVwViewModel.LoanChangeVwViewModel.Instance = loanVwViewModel.Instance.LoanChangeVw;

            @ViewBag.FromLoanChangeVwTitle = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "LoanChange", "ModuleNamePlural");
            // loanVwViewModel.FromLoanChangeVwViewModel.List = LoanChangeVwServices.GetByLoanId(product.Value, db);
            loanVwViewModel.FromLoanChangeVwViewModel.List = loanVwViewModel.Instance.FromLoanChangeVwList;


            @ViewBag.OutgoingLoanVwTitle = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "OutgoingLoan", "ModuleName");
            if (loanVwViewModel.Instance.OutgoingLoanVw != null)
            {
                loanVwViewModel.OutgoingLoanVwViewModel.List.Add(loanVwViewModel.Instance.OutgoingLoanVw);
            }
            // loanVwViewModel.OutgoingLoanVwViewModel.Instance = loanVwViewModel.Instance.OutgoingLoanVw;

            //loanVwViewModel.Instance.ProductVw =  ProductVwServices.Get(loanVwViewModel.Instance.ProductId);
            //loanVwViewModel.Instance.ProductVw.RefundableProductVw = RefundableProductVwServices.GetChildren(loanVwViewModel.Instance.ProductId);

            @ViewBag.InstallmentVwTitle = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "Installment", "ModuleNamePlural");
            // refundableProductVwViewModel.InstallmentVwViewModel.List = InstallmentVwServices.GetByRefundableProductId(product.Value, db);
            //loanVwViewModel.Instance.ProductVw.RefundableProductVw.InstallmentVwList = loanVwViewModel.Instance.ProductVw.RefundableProductVw.InstallmentVwList;//InstallmentVwServices.GetByRefundableProductProductId(loanVwViewModel.Instance.ProductId);


            loanVwViewModel.InstallmentsResultList = DbServices.GetInstallments(loanVwViewModel.Instance.ProductId);


            return(View(loanVwViewModel));
        }
Exemple #20
0
        } // Log

        static void UpdateDbStatus(int status)
        {
            using (var cmd = new SqlCeCommand())
            {
                cmd.CommandText = "INSERT INTO [Status] ([Status], [Timestamp]) VALUES (?, ?)";
                cmd.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value         = status;
                cmd.Parameters.Add("@Timestamp", System.Data.SqlDbType.DateTime).Value = DateTime.UtcNow;
                DbServices.Execute(DbFile, cmd);
            } // using cmd
        }     // UpdateDbStatus
Exemple #21
0
    protected void bnDelete_Click(object sender, EventArgs e)
    {
        string confirm = "Really delete!";

        if (bnDelete.Text == confirm)
        {
            DbServices.DeletePageByUrlpath(urlpath);
            Response.Redirect("./");
        }
        bnDelete.Text = confirm;
    }
            public void TestInsertInitialData()
            {
                var srv = new DbServices();

                srv.InsertInitialData();

                using (var ctx = new BankDbContext())
                {
                    var card = ctx.Cards.Single(c => c.CardId == "5111111111111111");
                }
            }
Exemple #23
0
    public DataTable getFullTable(string table)
    {
        #region DB functions
        StringBuilder sb = new StringBuilder();

        string     query = sb.AppendFormat("select * from {0} p;", table).ToString();
        DbServices db    = new DbServices();
        DataSet    ds    = db.GetDataSetByQuery(query);
        return(ds.Tables[0]);

        #endregion
    }
 public bool InsertCalculatedExpression(string clientIP, string expression)
 {
     try
     {
         DbServices.ExecuteInsertStoredProcedure("sp_InsertCalculatedExpressionByIP", new string[] { clientIP, expression });
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
 public bool DeleteCalculatedExpression(string Id)
 {
     try
     {
         DbServices.ExecuteDeleteStoredProcedure("sp_DeleteCalculatedExpression", new string[] { Id });
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #26
0
        public ActionResult PrintReportEmployeeLoansBetweenTwoDates(ReportEmployeeLoansBetweenTwoDatesFilter model)
        {
            try
            {
                ViewBag.Title = "Report";
                List <ReportEmployeeLoansBetweenTwoDatesResult> result = DbServices.ReportEmployeeLoansBetweenTwoDates(model, db);

                return(PartialView(result));
            }
            catch (CfException exc)
            {
                return(View());
            }
        }
        public ActionResult ReportSubscriptions(ReportSubscriptionsBetweenTwoDatesFilter filter)
        {
            try
            {
                List <ReportSubscriptionsBetweenTwoDatesResult> result = DbServices.ReportSubscriptionsBetweenTwoDates(filter, db);

                return(PartialView("ReportSubscriptionsResult", result));
            }
            catch (CfException exc)
            {
                ViewBag.ReportSubscriptions = reportSubscriptions;
                return(View());
            }
        }
        public List <CalculationsHistory> GetCalculationsHistoryByIPandCurrentDate(string clientIP)
        {
            DataSet ds = new DataSet();
            List <CalculationsHistory> calHistoryList = new List <CalculationsHistory>();

            DbServices.ExecuteStoreProcedure("sp_GetCalculationsHistoryByIPandCurrentDate", new string[] { clientIP }, "CalculationsHistory", ds);

            if (ds.Tables["CalculationsHistory"] != null && ds.Tables["CalculationsHistory"].Rows.Count > 0)
            {
                DataTable dt = ds.Tables["CalculationsHistory"];
                calHistoryList = dt.CreateListFromTable <CalculationsHistory>();
            }
            return(calHistoryList);
        }
        public T GetLastInsertedRow <T>(string tableName, string id = null) where T : new()
        {
            T item = new T();

            try
            {
                item = DbServices.GetLastInsertedDataFromTable <T>(tableName, id);
                return(item);
            }
            catch (Exception ex)
            {
                return(item);
            }
        }
Exemple #30
0
        public ActionResult PrintReportBalance(ReportMonthlyBalanceSumFilter model)
        {
            try
            {
                ViewBag.Title = "Report";
                List <ReportMonthlyBalanceSumResult> result = DbServices.ReportMonthlyBalanceSum(model, db);

                return(PartialView(result));
            }
            catch (CfException exc)
            {
                return(View());
            }
        }