Beispiel #1
0
        public ActionResult Dash()
        {
            DateTime date;

            date = Convert.ToDateTime((Convert.ToDateTime(TempData["date"])).ToString("yyyy-MM-dd"));
            Guid       IdG   = Guid.Parse(TempData["IdG"].ToString());
            var        list  = new List <ChartData>();
            HistoryBLL hs    = new HistoryBLL();
            var        list1 = hs.Checkdate(date, IdG);

            foreach (var item in list1)
            {
                ChartData cd = new ChartData();
                cd.amount = item.Amount;
                StatusBLL st = new StatusBLL();
                cd.name = (st.Getname(item.IdStatus));
                list.Add(cd);
            }
            List <int?>   am = new List <int?>();
            List <string> nm = new List <string>();

            foreach (var item in list)
            {
                am.Add(item.amount);
                nm.Add(item.name);
            }
            var rep = am;

            ViewBag.AMOUNT = am;
            ViewBag.NAME   = nm;

            return(View());
        }
Beispiel #2
0
 public Cli()
 {
     clientBLL       = new ClientBLL();
     historyBLL      = new HistoryBLL();
     optionBLL       = new OptionBLL();
     planBLL         = new PlanBLL();
     subOptionBLL    = new SubOptionBLL();
     subscriptionBLL = new SubscriptionBLL();
 }
Beispiel #3
0
 /// <summary>
 /// 保存历史记录
 /// </summary>
 /// <param name="obj"></param>
 protected void SaveHistory(TB_AccountHistory obj)
 {
     using (var bll = new HistoryBLL())
     {
         obj.ActionTime = DateTime.Now;
         if (obj.Account <= 0 || (int?)null == obj.Account)
         {
             obj.Account = Account.id;
         }
         obj.Ip = Utility.GetClientIP(this.Context);
         bll.Add(obj);
     }
 }
        public bool Insert(HistoryBLL p)
        {
            //Creating Boolean Variable and set its default value to false
            bool isSuccess = false;

            //Sql Connection for Database
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //SQL Query to insert Patients into database
                String sql = "INSERT INTO tbl_History (FileNumber, AppointmentID, AdmissionID, AccountID, PrescriptionID) VALUES (@FileNumber, @AppointmentID, @AdmissionID, @AccountID, @PrescriptionID)";

                //Creating SQL Command to pass the values
                SqlCommand cmd = new SqlCommand(sql, conn);

                //Passign the values through parameters
                cmd.Parameters.AddWithValue("@FileNumber", p.FileNumber);
                cmd.Parameters.AddWithValue("@AppointmentID", p.AppointmentID);
                cmd.Parameters.AddWithValue("@AdmissionID", p.AdmissionID);
                cmd.Parameters.AddWithValue("@AccountID", p.AccountID);
                cmd.Parameters.AddWithValue("@PrescriptionID", p.PrescriptionID);

                //Opening the Database connection
                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                //If the query is executed successfully then the value of rows will be greater than 0 else it will be less than 0
                if (rows > 0)
                {
                    //Query Executed Successfully
                    isSuccess = true;
                }
                else
                {
                    //Failed to Execute Query
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
Beispiel #5
0
        public HttpResponseMessage Get(String clientId)
        {
            try
            {
                HistoryBLL     bll      = new HistoryBLL();
                List <History> historic = bll.ListarPorId(clientId);

                return(new HttpResponseMessage()
                {
                    Content = new StringContent(JArray.FromObject(historic).ToString(), Encoding.UTF8, "application/json")
                });
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { message = ex.Message.ToString() }));
            }
        }
Beispiel #6
0
        /// <summary>
        /// 查询以设备号码为基准的绑定、解绑历史记录
        /// </summary>
        /// <returns></returns>
        private string HandleEquipmentBindHistory()
        {
            var ret = "[]";

            try
            {
                using (var bll = new HistoryBLL())
                {
                    var list = bll.FindList <TB_AccountHistory>(f => (f.ActionId == 38 || f.ActionId == 47) && f.ObjectA.Contains(data), "ActionTime");
                    var tmp  = new List <TempAsHistory>();
                    foreach (var obj in list)
                    {
                        tmp.Add(new TempAsHistory(obj));
                    }
                    ret = JsonConverter.ToJson(tmp);
                }
            }
            catch { }
            return(ret);
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Create Client");
            ClientBLL clientBLL    = new ClientBLL();
            IClient   clientThomas = clientBLL.Create("Thomas", new DateTime(1980, 3, 25));

            System.Console.WriteLine("Create Plan");
            PlanBLL planBLL = new PlanBLL();
            IPlan   planNoSMS;

            try
            {
                planNoSMS = planBLL.Create("No SMS <3", -2, 0, 15, -.30M, 0.15M, true);
            }
            catch (DbEntityValidationException dbEx)
            {
                printValidationException(dbEx);
                planNoSMS = planBLL.Create("No SMS ", -1, 0, 15, .30M, 0.15M, true);
            }


            System.Console.WriteLine("Create Subscription");
            SubscriptionBLL subscriptionBLL    = new SubscriptionBLL();
            ISubscription   subscriptionThomas = subscriptionBLL.Create(
                planNoSMS.GetPlanId(),
                clientThomas.GetClientId(),
                "06234235262",
                DateTime.Now,
                null);

            String phoneNumber = subscriptionThomas.GetPhoneNumber();

            System.Console.WriteLine("Searching client by phone number : " + phoneNumber);
            IClient clientThomas2 = clientBLL.GetByPhoneNumber(phoneNumber);

            if (clientThomas2 != null)
            {
                System.Console.WriteLine("client Thomas found by phone number : " + clientThomas2.GetClientId());
            }
            else
            {
                System.Console.WriteLine("client not found");
            }

            System.Console.WriteLine("Update phone number");
            subscriptionThomas.SetPhoneNumber("0623425262");
            subscriptionBLL.Update(subscriptionThomas);

            System.Console.WriteLine();
            System.Console.WriteLine("List all clients");
            foreach (IClient client in clientBLL.GetAll())
            {
                System.Console.WriteLine(client.GetName() +
                                         " id " + client.GetClientId() +
                                         " borne on " + client.GetBirthday().ToShortDateString());
            }

            System.Console.WriteLine();
            System.Console.WriteLine("List all plans");
            foreach (IPlan plan in planBLL.GetAll())
            {
                System.Console.WriteLine(plan.GetName() +
                                         " id " + plan.GetPlanId());
            }

            System.Console.WriteLine();
            System.Console.WriteLine("List all subscriptions");
            foreach (ISubscription subscription in subscriptionBLL.GetAll())
            {
                System.Console.WriteLine(subscription.GetPhoneNumber() +
                                         " id " + subscription.GetSubscriptionId());
            }


            System.Console.WriteLine();
            System.Console.WriteLine("Creating some SMS and Call History");
            List <IHistory> Histories = new List <IHistory>();

            HistoryBLL historyBLL = new HistoryBLL();

            string[] phone_nums = { "(1) (415) 123-1234",
                                    "(415) 123-1234",
                                    "1-800-123-1234",
                                    "206/782-8410",
                                    "206.782.8410",
                                    "05324225543",
                                    "+335324225543",
                                    "206 782 8410 ",
                                    "206-782-8410",
                                    "(206) 782-8410",
                                    "555-555-5555",
                                    "05324+343" };

            foreach (string phone_num in phone_nums)
            {
                try
                {
                    System.Console.WriteLine("Create hist with  : " + phone_num);
                    ISMSHistory  history = historyBLL.CreateSMS(subscriptionThomas.GetSubscriptionId(), DateTime.Now, phone_num, "+33");
                    ICallHistory call    = historyBLL.CreateVoice(subscriptionThomas.GetSubscriptionId(), DateTime.Now, phone_num, "+33", 35);
                    Thread.Sleep(1000);
                    Histories.Add(history);
                    Histories.Add(call);
                }
                catch (InvalidFormatException e)
                {
                    System.Console.WriteLine(e.Message);
                }
                catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }
            }

            System.Console.WriteLine();
            System.Console.WriteLine("List all history");

            foreach (IHistory histor in historyBLL.GetAll())
            {
                if (histor is ICallHistory)
                {
                    System.Console.WriteLine("Phone call : " + histor.GetTimestamp()
                                             + " FROM : " + subscriptionBLL.GetById(histor.GetSubscriptionId()).GetPhoneNumber()
                                             + " TO : " + histor.GetDestinationNumber()
                                             + " DURING  : " + ((ICallHistory)histor).GetDuration() + " Seconds");
                }
                else
                {
                    System.Console.WriteLine("SMS : " + histor.GetTimestamp()
                                             + " FROM : " + subscriptionBLL.GetById(histor.GetSubscriptionId()).GetPhoneNumber()
                                             + " TO : " + histor.GetDestinationNumber());
                }
                historyBLL.Delete(histor);
            }

            System.Console.WriteLine();
            System.Console.WriteLine("Creating some options");
            OptionBLL optionBLL = new OptionBLL();
            IOption   option    = optionBLL.Create("SMSBooster", 0, 100, 10, false);

            System.Console.WriteLine();
            System.Console.WriteLine("List all options");
            foreach (IOption opt in optionBLL.GetAll())
            {
                System.Console.WriteLine("Option : " + opt.GetName()
                                         + " minute limit : " + opt.GetMinuteLimit()
                                         + " sms limit : " + opt.GetSMSLimit()
                                         + " price : " + opt.GetPrice()
                                         + " is available : " + opt.GetIsAvailable());
            }

            System.Console.WriteLine();
            System.Console.WriteLine("Creating SubOption");
            SubOptionBLL subOptionBLL = new SubOptionBLL();
            ISubOption   subOption    = subOptionBLL.Create(subscriptionThomas.GetSubscriptionId(), option.GetOptionId(), DateTime.Today, DateTime.Today.AddDays(10));

            System.Console.WriteLine();
            System.Console.WriteLine("Listing SubOptions");

            foreach (ISubOption opt in subOptionBLL.GetAll())
            {
                string res = "SubOption subscriptor : " + subscriptionBLL.GetById(opt.GetSubscriptionId()).GetPhoneNumber()
                             + " for option : " + optionBLL.GetById(opt.GetOptionId()).GetName()
                             + " Started on : " + opt.GetStartDate().ToShortDateString();
                if (opt.GetEndDate() != null)
                {
                    res += " Ending on : " + ((DateTime)opt.GetEndDate()).ToShortDateString();
                }
                System.Console.WriteLine(res);
            }


            System.Console.WriteLine();
            System.Console.WriteLine("Trying to break the system ");
            int nb = 0;

            try
            {
                clientBLL.Create("Thoma$", new DateTime(1980, 3, 25));
                System.Console.WriteLine("Got {0} :) ", ++nb);
            }
            catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }

            try
            {
                clientBLL.Create("Thomas", DateTime.Today.AddDays(3));
                System.Console.WriteLine("Got {0} :) ", ++nb);
            }
            catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }


            try
            {
                planBLL.Create("<3", 0, 0, 0, 0, 0, false);
                System.Console.WriteLine("Got {0} :) ", ++nb);
            }
            catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }


            try
            {
                planBLL.Create("love", -2, -2, -2, -2, -2, false);
                System.Console.WriteLine("Got one :) "); nb++;
            }
            catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }

            try
            {
                subscriptionBLL.Create(1, 1, "+3345566786", DateTime.Today, DateTime.Today.AddDays(-3));
                System.Console.WriteLine("Got one :) "); nb++;
            }
            catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }

            try
            {
                optionBLL.Create("<3", -2, -2, -1, true);
                System.Console.WriteLine("Got one :) "); nb++;
            }
            catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }

            try
            {
                subOptionBLL.Create(1, 1, DateTime.Today, DateTime.Today.AddDays(-3));
                System.Console.WriteLine("Got one :) "); nb++;
            }
            catch (DbEntityValidationException dbEx) { printValidationException(dbEx); }

            subOptionBLL.Delete(subOption);
            optionBLL.Delete(option);
            subscriptionBLL.Delete(subscriptionThomas);
            clientBLL.Delete(clientThomas);
            planBLL.Delete(planNoSMS);


            System.Console.Read();
        }
Beispiel #8
0
        // GET: ReciveEmail
        public ActionResult Index(string code, int number, string date)
        {
            string ngayht = Encrypt.sha1("" + DateTime.Now.Date);

            if (ngayht != date)
            {
                ViewBag.message = "Đã quá hạn để xác nhận. Xin cảm ơn!";
            }
            else
            {
                OUsers  user    = new OUsers();
                UserBLL userbll = new UserBLL();
                // lấy tất cả các user chưa gửi khảo sát
                var dsus = userbll.GetallBycheck(0);
                if (dsus == null) // kiểm tra nếu danh sách rỗng thì gửi message
                {
                    ViewBag.message = "Bạn đã làm khảo sát ngày hôm nay. Xin cảm ơn ";
                }
                else // nếu không thì kiểm tra tiếp
                {
                    foreach (var item in dsus) //kiểm tra có id nào trùng với id đã gửi về k. nếu có thì gán vào biến user
                    {
                        string ma = Encrypt.sha1("" + item.IdUser);
                        if (ma == code)
                        {
                            user = item;
                        }
                    }
                }
                // kiểm tra biến user có giá trị k
                if (user.IdUser != Guid.Empty) //nếu có
                {
                    HistoryBLL hisbll = new HistoryBLL();
                    //kiểm tra xem đã có bản ghi ngày hôm nay chưa
                    var kttontai = from table in hisbll.Getall()
                                   where table.CreationDate == DateTime.Now.Date
                                   select table;
                    if (kttontai == null) //nếu không có thì thêm mới.
                    {
                        OHistories history = new OHistories();
                        history.IdHis        = Guid.NewGuid();
                        history.CreationDate = DateTime.Now.Date;
                        history.IdStatus     = number;
                        history.IdGroup      = user.IdGroup;
                        hisbll.Insert(history);
                    }
                    else // nếu đã có bản ghi ngày hôm nay
                    {
                        bool kq = false;
                        foreach (var item in kttontai)
                        {
                            if (item.IdStatus == number) // kiểm tra xem có bản ghi của loại trạng thái đã truyền về không
                            {
                                hisbll.Update(item);     //nếu có. update bản ghi
                                kq = true;
                            }
                        }
                        if (kq == false) // nếu không có thì tạo bản ghi mới với trạng thái đấy
                        {
                            OHistories history = new OHistories();
                            history.IdHis        = Guid.NewGuid();
                            history.CreationDate = DateTime.Now.Date;
                            history.IdStatus     = number;
                            history.IdGroup      = user.IdGroup;
                            hisbll.Insert(history);
                        }
                    }
                    // sửa user thành đã làm khảo sát
                    user.Checkmail = true;
                    userbll.Updatecheckmail(user, 1);
                    ViewBag.message = "Cảm ơn bạn đã khảo sát. Xin cảm ơn !";
                }
                else
                {
                    ViewBag.message = "Bạn đã làm khảo sát ngày hôm nay. Xin cảm ơn ";
                }
            }
            return(View());
        }
Beispiel #9
0
        protected void btnGotoport_OnClick(object sender, EventArgs e)
        {
            //1、网页端申请车位 数据写入数据库 生成订单、活跃订单、
            //2、车库端3s / 次进行循环读取 读取完成再更改数据(分配的车位)
            //3、网页端等待1.5s后再次访问数据库失败则进行循环 使用try catch 防止同时读取 获取分配到的车位号
            string     CarNum     = this.rblCarNum.SelectedItem.Text;
            string     parkName   = this.txbPortName.Value;
            HistoryBLL historyBll = new HistoryBLL();
            //生成活跃订单
            ApplyInfo apply = new ApplyInfo();

            apply.HID           = historyBll.GetNewHID() + 1;
            apply.CarNum        = CarNum;
            apply.ParkID        = new PartInfoBLL().GetIdByName(parkName);
            apply.ParkPosintion = "null";
            apply.State         = 0;
            if (new ApplyInfoBLL().CreateOrder(apply))
            {
                //保存失败
                AppHelper.Helper.jsPrint("出现了某些错误!(。・_・。)ノI’m sorry~   错误代码:#APL01");
                return;
            }
            //生成历史订单
            History his = new History();

            his.UserName      = (Session["UserInfo"] as UserInfo).UserName;
            his.BookTime      = DateTime.Now;
            his.StartTime     = Convert.ToDateTime("2000-1-1");
            his.EndTime       = Convert.ToDateTime("2000-1-1");
            his.AllTime       = Convert.ToDateTime("2000-1-1");
            his.CarNum        = CarNum;
            his.PortName      = parkName;
            his.PortPrice     = Convert.ToDecimal(this.txbPrice.Value);
            his.State         = -1;
            his.Cost          = Convert.ToDecimal(0);
            his.ParkPosintion = "-1";
            if (historyBll.SaveHistory(his))
            {
                //保存失败
                AppHelper.Helper.jsPrint("出现了某些错误!(。・_・。)ノI’m sorry~   错误代码:#HIS01");
                return;
            }

            //等待结果
            for (int i = 0; i < 5; i++)
            {
                Thread.Sleep(1500);
                ApplyInfo apply_GetMsg = new ApplyInfoBLL().QueryOrderResult(historyBll.GetNewHID().ToString());
                //车位分配好
                if (apply_GetMsg.State == 1)
                {
                    //分配已完成 转移数据
                    if (historyBll.UpdateParkPosition(apply_GetMsg.ParkPosintion, apply_GetMsg.HID))
                    {
                        AppHelper.Helper.jsPrint("出现了某些错误!(。・_・。)ノI’m sorry~   错误代码:#HIS02");
                        return;
                    }
                    //未完成 跳转到其他页面单独进行导航
                    AppHelper.Helper.jsPrint("OK");
                }
            }
        }
Beispiel #10
0
        public HttpResponseMessage Post()
        {
            try
            {
                System.Threading.Tasks.Task <string> content = Request.Content.ReadAsStringAsync();
                Object jobj = new object();

                var orderId = new TransactionLibrary().GetOrderId();

                //dados da operação
                jobj = JObject.Parse(content.Result);
                JToken client_id    = JObject.Parse(jobj.ToString()).SelectToken("client_id");
                JToken cart_id      = JObject.Parse(jobj.ToString()).SelectToken("cart_id");
                JToken client_name  = JObject.Parse(jobj.ToString()).SelectToken("client_name");
                JToken value_to_pay = JObject.Parse(jobj.ToString()).SelectToken("value_to_pay");
                JToken credit_card  = JObject.Parse(jobj.ToString()).SelectToken("credit_card");

                #region Cartão de Crédito
                //dados do cartão de crédito
                jobj = JObject.Parse(credit_card.ToString());
                JToken number           = JObject.Parse(jobj.ToString()).SelectToken("number");
                JToken cvv              = JObject.Parse(jobj.ToString()).SelectToken("cvv");
                JToken exp_date         = JObject.Parse(jobj.ToString()).SelectToken("exp_date");
                JToken card_holder_name = JObject.Parse(jobj.ToString()).SelectToken("card_holder_name");

                CreditCard creditCard = new CreditCard();
                creditCard.card_number      = number.ToString();
                creditCard.cvv              = Convert.ToInt32(cvv);
                creditCard.exp_date         = exp_date.ToString();
                creditCard.card_holder_name = card_holder_name.ToString();

                //registra o cartão de crédito
                CreditCardBLL creditCardBll = new CreditCardBLL();
                creditCardBll.Inserir(creditCard);
                #endregion

                #region Transação
                //registra a transação de venda
                Transaction transaction = new Transaction();
                transaction.client_id    = client_id.ToString();
                transaction.cart_id      = cart_id.ToString();
                transaction.client_name  = client_name.ToString();
                transaction.total_to_pay = Convert.ToInt32(value_to_pay);
                transaction.credit_card  = creditCard.card_number;
                transaction.order_id     = orderId;
                transaction.date         = DateTime.Today.ToString("dd/MM/yyyy");

                TransactionBLL transactionBll = new TransactionBLL();
                transactionBll.Inserir(transaction);
                #endregion

                #region Histórico
                History history = new History();
                history.card_number = creditCard.card_number;
                history.client_id   = transaction.client_id;
                history.value       = transaction.total_to_pay;
                history.order_id    = orderId;

                HistoryBLL historyBll = new HistoryBLL();
                historyBll.Inserir(history);
                #endregion

                return(Request.CreateResponse(HttpStatusCode.OK, new { message = "Compra realizada com sucesso!" }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { message = ex.Message.ToString() }));
            }
        }