Esempio n. 1
0
        private void GetCustomerTransportTofuReportData(DateTime date)
        {
            string ReportName = ((KeyValuePair <string, string>)ddlReportName.SelectedItem).Value;

            using (var dailydb = new OrderEntities())
            {
                List <GetCustomerTransportTofu_Result> ds = null;
                ds = dailydb.GetCustomerTransportTofu(date).ToList();

                if (ds.Count() > 0)
                {
                    string          datestring = HelperCS.DateTextThai(date, "TH", "dd MMM yyyy");
                    string          day        = HelperCS.daythai[(int)date.DayOfWeek - 1];
                    ReportParameter p1         = new ReportParameter("Date", datestring);
                    ReportParameter p2         = new ReportParameter("ReportName", ReportName);
                    ReportParameter p3         = new ReportParameter("Day", day);
                    reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3 });
                    OrderBindingSource.DataSource = HelperCS.ToDataTable(ds);
                    ReportDataSource rtpsource1 = new ReportDataSource("DataSet1", OrderBindingSource);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource1);
                }
                else
                {
                    OrderBindingSource.DataSource = null;
                }
            }
        }
Esempio n. 2
0
        public IHttpActionResult Add(int foodId)
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    var f = new Food();
                    //Lay mon an co Id == id truyen vao trong bang Foods
                    f = db.Foods.Where(x => x.Id == foodId).FirstOrDefault();

                    //Lay mon an co FoodId = id truyen vao trong bang Orders
                    var o = db.Orders.Where(x => x.FoodId == foodId).FirstOrDefault();

                    //Kiem tra trong Orders da ton tai mon an co FoodId = id truyen vao chua
                    if (o == null)                    //neu chua => them vao
                    {
                        var order = new Order();
                        order.FoodId = f.Id;
                        order.Name   = f.Name;
                        order.Qty    = 1;
                        order.Price  = f.Price;
                        order.Total  = order.Price * order.Qty;

                        db.Orders.Add(order);
                    }
                    else                    //neu ton tai thi tang so luong len 1
                    {
                        o.Qty++;
                    }
                    //var detail = new Detail();
                    //detail.AccountId = f.Restaurant.Id;

                    db.SaveChanges();

                    var res = db.Restaurants.Where(x => x.Id == f.RestaurantId).FirstOrDefault();
                    var r   = new Restaurant()
                    {
                        Name = res.Name
                    };

                    return(Json(new
                    {
                        Message = "Success",
                        Result = r,
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = new List <Food>(),
                    Code = 400
                }
                           ));
            }
        }        //end Add
Esempio n. 3
0
        private void GetProductTransportReportData(DateTime date, int customerzone)
        {
            string ReportName = ((KeyValuePair <string, string>)ddlReportName.SelectedItem).Value;
            string driver     = ((KeyValuePair <string, string>)ddlCustomer.SelectedItem).Value;

            using (var dailydb = new OrderEntities())
            {
                var ds = dailydb.GetProductTransport(date, customerzone).ToList();

                if (ds.Count() > 0)
                {
                    string          datestring = HelperCS.DateTextThai(date, "TH", "dd MMM yyyy");
                    string          day        = HelperCS.daythai[(int)date.DayOfWeek - 1];
                    ReportParameter p1         = new ReportParameter("Date", datestring);
                    //ReportParameter p1 = new ReportParameter("Date", date.ToString("yyyy-MM-dd"));
                    ReportParameter p2 = new ReportParameter("Zone", driver);
                    ReportParameter p3 = new ReportParameter("ReportName", ReportName);
                    ReportParameter p4 = new ReportParameter("Day", day);
                    reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4 });
                    OrderBindingSource.DataSource = HelperCS.ToDataTable(ds);
                    ReportDataSource rtpsource1 = new ReportDataSource("DataSet1", OrderBindingSource);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource1);
                }
                else
                {
                    OrderBindingSource.DataSource = null;
                }
            }
        }
Esempio n. 4
0
        private void btnSubmitLogin_Click(object sender, EventArgs e)
        {
            using (OrderEntities db = new OrderEntities())
            {
                string passwd = txtPassword.Text != "" ? HelperCS.Encrypt(txtPassword.Text) : "";
                string usr    = txtUserName.Text != "" ? txtUserName.Text.ToUpper() : "";

                rownum = db.Login.Where(a => a.UserName == usr && a.Password == passwd).Count();
                if (rownum > 0)
                {
                    //DataInfo.UserLoginName = txtUserName.Text;
                    HelperCS.UserName = usr;
                    Form1 frm = this.FindForm() as Form1;
                    //frm.CheckUserLogin(txtUserName.Text);
                    //frm.pa
                    frm.CheckUserLogin();
                    //password anan168,ac2018
                }
                else
                {
                    lblLoginValidate.Text    = "";
                    lblLoginValidate.Text    = "** InValid Username or Password ";
                    lblLoginValidate.Visible = true;
                }
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdCode,CustomerId,LaundryTypeId,AmountUnit,OrderType,Description,TotalPayment,Status")] OrderEntities orderEntities)
        {
            if (id != orderEntities.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderEntities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderEntitiesExists(orderEntities.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderEntities));
        }
Esempio n. 6
0
        public IHttpActionResult Delete(int foodId)
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    //var order = new List<Order>();

                    var order = db.Orders.Where(x => x.FoodId == foodId).SingleOrDefault();
                    if (order != null)
                    {
                        db.Orders.Remove(order);
                        db.SaveChanges();
                    }

                    return(Json(new
                    {
                        Message = "Success",
                        Result = "Delete success",
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = "Error ^^",
                    Code = 400
                }
                           ));
            }
        }        //end delete
        public virtual void FixtureSetup()
        {
            OrdersContextProvider = () =>
            {
                var orderEntities = new OrderEntities();
                orderEntities.ContextOptions.LazyLoadingEnabled = true;
                return(orderEntities);
            };

            HRContextProvider = () =>
            {
                var hrEntities = new HREntities();
                hrEntities.ContextOptions.LazyLoadingEnabled = true;
                return(hrEntities);
            };

            UnitOfWorkFactory = new EFUnitOfWorkFactory();
            UnitOfWorkFactory.RegisterContextProvider(HRContextProvider);
            UnitOfWorkFactory.RegisterContextProvider(OrdersContextProvider);

            Locator = MockRepository.GenerateStub <IServiceLocator>();
            Locator.Stub(x => x.GetInstance <IUnitOfWorkFactory>()).Return(UnitOfWorkFactory);
            Locator.Stub(x => x.GetInstance <IState>()).Do(new Func <IState>(() => State));
            ServiceLocator.SetLocatorProvider(() => Locator);
        }
Esempio n. 8
0
 private static int getCount(string tablename)
 {
     using (var db = new OrderEntities())
     {
         if (tablename == "Product")
         {
             // Get result from Stored Procedure
             var query = (from x in db.Product
                          where x.Status == true
                          select x).Count();
             return(query);
         }
         else if (tablename == "Customer")
         {
             // Get result from Stored Procedure
             var query = (from x in db.Product
                          where x.Status == true
                          select x).Count();
             return(query);
         }
         else
         {
             return(0);
         }
     }
 }
Esempio n. 9
0
        private void GetInvoiceReportData(DateTime date, int customer)
        {
            string ReportName = ((KeyValuePair <string, string>)ddlReportName.SelectedItem).Value;

            using (var dailydb = new OrderEntities())
            {
                var ds1 = (from x in dailydb.vwCustomerDetail
                           where x.CustomerID == customer
                           select x).ToList();
                var ds2 = dailydb.GetOrderbyDay(date, customer).ToList();
                if (ds1.Count() > 0 && ds2.Count() > 0)
                {
                    ReportParameter p1 = new ReportParameter("ReportType", ReportName);
                    ReportParameter p2 = new ReportParameter("Date", RptDatePicker.Value.ToLongDateString());
                    ReportParameter p3 = new ReportParameter("DocumentNo", "INV");
                    ReportParameter p4 = new ReportParameter("BahtText", BahtToText(ds2));

                    reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4 });

                    CustomerBindingSource.DataSource = HelperCS.ToDataTable(ds1);
                    OrderBindingSource.DataSource    = HelperCS.ToDataTable(ds2);
                    ReportDataSource rtpsource1 = new ReportDataSource("DataSet1", CustomerBindingSource);
                    ReportDataSource rtpsource2 = new ReportDataSource("DataSet2", OrderBindingSource);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource1);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource2);
                }
                else
                {
                    OrderBindingSource.DataSource = null;
                }
            }
        }
Esempio n. 10
0
        private void btnEditPrice_Click(object sender, EventArgs e)
        {
            DialogResult res = InputBox.ShowDialog("กรุณาใส่รหัสเพื่อแก้ไขราคาสินค้า:",
                                                   "Authentication",                                                        //Text message (mandatory), Title (optional)
                                                   InputBox.Icon.Exclamation,                                               //Set icon type (default info)
                                                   InputBox.Buttons.OkCancel,                                               //Set buttons (default ok)
                                                   InputBox.Type.TextBoxPassword,                                           //Set type (default nothing)
                                                   new string[] { "Item1", "Item2", "Item3" },                              //String field as ComboBox items (default null)
                                                   true,                                                                    //Set visible in taskbar (default false)
                                                   new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold)); //Set font (default by system)

            if (res == System.Windows.Forms.DialogResult.OK || res == System.Windows.Forms.DialogResult.Yes)
            {
                using (OrderEntities db = new OrderEntities())
                {
                    string passwd = InputBox.ResultValue != "" ? HelperCS.Encrypt(InputBox.ResultValue) : ""; //InputBox.ResultValue = textbox form dialogresult
                    int    rownum = db.Login.Where(a => a.UserName == "PRICE" && a.Password == passwd).Count();
                    if (rownum > 0)
                    {
                        log.Info("OrderUC:Edit Price user:"******" customerid:" + ComboOrderCustomer.SelectedItem.ToString() + " day:" + HelperCS.daycheckbox.ToString());
                        HelperCS.editprice = true;
                        CheckTabActive();
                    }
                    else
                    {
                        log.Error("OrderUC:Edit Price Error user:"******" customerid:" + ComboOrderCustomer.SelectedItem.ToString() + " day:" + HelperCS.daycheckbox.ToString());
                        Form frm = btnEditPrice.FindForm();
                        MessageBox.Show(frm, "คุณไม่มีสิทธิ์แก้ไขข้อมูล ", "Authorization Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Esempio n. 11
0
 public CompositeOrderEntity(IEnumerable <OrderEntity> orderEntities)
 {
     OrderEntities = orderEntities?.ToArray() ?? throw new ArgumentNullException(nameof(orderEntities));
     if (OrderEntities.Count() < 1)
     {
         throw new ArgumentException("composite order entity must has at least one element", nameof(orderEntities));
     }
 }
Esempio n. 12
0
        public async Task <IActionResult> Create([Bind("Id,IdCode,CustomerId,LaundryTypeId,AmountUnit,OrderType,Description,TotalPayment,Status")] OrderEntities orderEntities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderEntities);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderEntities));
        }
Esempio n. 13
0
        public IHttpActionResult GetList(int restaurantId)
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    //add res to ss
                    var res = db.Restaurants.Where(x => x.Id == restaurantId).FirstOrDefault();
                    if (db.Sessions.Count() == 0)
                    {
                        var ss = new Session();
                        ss.RestaurantId = res.Id;
                        ss.Date         = DateTime.Now;
                        ss.Status       = false;
                        db.Sessions.Add(ss);
                        db.SaveChanges();
                    }
                    //Get cate
                    var se         = db.Sessions.FirstOrDefault();
                    var categories = new List <Category>();

                    categories = db.Categories.Where(x => x.RestaurantId == se.RestaurantId).ToList();

                    var cate = categories.Select(s => new Category()
                    {
                        Id           = s.Id,
                        Name         = s.Name,
                        RestaurantId = s.RestaurantId,
                        Icon         = s.Icon
                    });



                    return(Json(new
                    {
                        Message = "Success",
                        Result = cate,
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = new List <Category>(),
                    Code = 400
                }
                           ));
            }
        }
Esempio n. 14
0
        /// <summary>
        /// IN this method, we are going to save the new record in the database on the bases of date
        /// </summary>
        /// <param name="newProductsList"></param>
        private static void SaveProducts(List <Order> newProductsList)
        {
            using (OrderEntities db = new OrderEntities())
            {
                var Orders = db.Orders.ToList();

                var result = newProductsList.Where(p => !Orders.Any(p2 => p2.Datetest == p.Datetest)).ToList();
                //var result = newProductsList.Where(p => Orders.Any(p2 => Convert.ToDateTime(p2.date).ToShortDateString() == Convert.ToDateTime(p.date).ToShortDateString())).ToList();
                Console.WriteLine("No of new records in the Csv file " + result.Count.ToString());
                if (result.Count > 0)
                {
                    db.Orders.AddRange(result);
                    db.SaveChanges();
                }
            }
        }
 private void DeleteCustomerData()
 {
     try
     {
         if (customerid > 0)
         {
             //delete customer set status = 0 (false)
             int queryresult = 0;
             using (var db = new OrderEntities())
             {
                 var ds = db.DeleteRecord("Customer", customerid, DateTime.Now, HelperCS.UserName).ToList();
                 if (ds.Count() > 0)
                 {
                     queryresult = ds[0] != null?int.Parse(ds[0].ToString()) : 99;
                 }
                 else
                 {
                     queryresult = 99;
                 }
             }
             if (queryresult != 0)
             {
                 MessageBox.Show("มีปัญหาในการลบข้อมูล", "ลบข้อมูลไม่ได้", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 MessageBox.Show("ลบข้อมูลลูกค้า " + txtbCustomerName.Text + " เรียบร้อย", "ลบข้อมูล", MessageBoxButtons.OK, MessageBoxIcon.None);
                 ((Form)this.TopLevelControl).Close();
             }
         }
         else
         {
             MessageBox.Show("มีปัญหาในการลบข้อมูล \r\n ไม่มีข้อมูลลูกค้า", "ลบข้อมูลไม่ได้", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("มีปัญหาในการลบข้อมูล \r\n" + ex.Message, "ลบข้อมูลไม่ได้", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         customerid = 0;
         ((Form)this.TopLevelControl).Close();
     }
 }
        public IActionResult getOrder(int id)
        {
            string        username    = User.Identity.Name;
            var           order       = context.Orders.Where(order => order.Username.Equals(username)).ToList().FirstOrDefault(order => order.OrderId.Equals(id));
            OrderEntities orderResult = null;

            if (order != null)
            {
                orderResult                = new OrderEntities();
                orderResult.OrderId        = order.OrderId;
                orderResult.Username       = order.Username;
                orderResult.OrderPaymethod = order.OrderPaymethod;
                orderResult.OrderStatus    = order.OrderStatus;
                orderResult.lstOrderDetail = context.OrderDetail.Where(orderdetail => orderdetail.OrderId.Equals(order.OrderId)).Select(orderdetail => new OrderEntities.OrderDetailEntities(orderdetail.ProductId, orderdetail.OrderdetailCount)).ToList();
            }

            return(Ok(orderResult));
        }
Esempio n. 17
0
        private DataTable DataEntity()
        {
            using (var dailydb = new OrderEntities())
            {
                // Get result from Stored Procedure

                var ds = dailydb.GetDailyOrder("Monday", 1).ToList();

                // if found item rows
                if (ds.Count() > 0)
                {
                    return(HelperCS.ToDataTable(ds));
                }
                else
                {
                    return(new DataTable());
                }
            }
        }
Esempio n. 18
0
        //private void LoadReport()
        //{
        //    reportViewer1.ProcessingMode = ProcessingMode.Local;

        //    //string date = "16/11/2017";
        //    //DateTime dt = Convert.ToDateTime(date);

        //    //GetSalesOrderData(dt,  3);
        //}

        #region GET REPORT DATA
        private void GetSalesOrderData(DateTime date, int customer)
        {
            using (var dailydb = new OrderEntities())
            {
                // Get result from Stored Procedure
                var ds = dailydb.GetOrderbyDay(date, customer).ToList();
                //OrderUC orderUC = new OrderUC();
                if (ds.Count() > 0)
                {
                    OrderBindingSource.DataSource = HelperCS.ToDataTable(ds);
                    ReportDataSource rtpsource = new ReportDataSource("DataSet1", OrderBindingSource);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource);
                }
                else
                {
                    OrderBindingSource.DataSource = null;
                }
            }
        }
Esempio n. 19
0
        public IHttpActionResult Close()
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    //var order = new List<Order>();

                    var order = db.Orders.ToList();
                    for (int i = 0; i < order.Count; i++)
                    {
                        db.Orders.Remove(order[i]);
                    }
                    var session = db.Sessions.FirstOrDefault();
                    db.Sessions.Remove(session);
                    for (int i = 0; i < order.Count; i++)
                    {
                        db.Orders.Remove(order[i]);
                    }

                    db.SaveChanges();

                    return(Json(new
                    {
                        Message = "Success",
                        Result = "Close success",
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = "Error ^^",
                    Code = 400
                }
                           ));
            }
        }        //end delete
Esempio n. 20
0
        public IHttpActionResult Info()
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    //var order = new List<Order>();

                    var session = db.Sessions.FirstOrDefault();
                    var res     = db.Restaurants.Where(x => x.Id == session.RestaurantId).FirstOrDefault();


                    var r = new Restaurant()
                    {
                        Id      = res.Id,
                        Name    = res.Name,
                        Address = res.Address,
                        Phone   = res.Phone
                    };



                    return(Json(new
                    {
                        Message = "Success",
                        Result = r,
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = "Error ^^",
                    Code = 400
                }
                           ));
            }
        }        //end
        public IActionResult getAllOrders()
        {
            string username       = User.Identity.Name;
            var    lstOrder       = context.Orders.Where(order => order.Username.Equals(username)).ToList();
            var    lstOrderResult = new List <OrderEntities>();

            foreach (Orders order in lstOrder)
            {
                var orderResult = new OrderEntities();
                orderResult.OrderId        = order.OrderId;
                orderResult.Username       = order.Username;
                orderResult.OrderPaymethod = order.OrderPaymethod;
                orderResult.OrderStatus    = order.OrderStatus;
                orderResult.lstOrderDetail = context.OrderDetail.Where(orderdetail => orderdetail.OrderId.Equals(order.OrderId)).Select(orderdetail => new OrderEntities.OrderDetailEntities(orderdetail.ProductId, orderdetail.OrderdetailCount)).ToList();

                lstOrderResult.Add(orderResult);
            }

            return(Ok(lstOrderResult));
        }
Esempio n. 22
0
        private DataTable DataEntityProduct()
        {
            using (var db = new OrderEntities())
            {
                // Get result from Stored Procedure
                //db.sims.Where(x => x.has_been_modified).ToList();
                var ds = (from x in db.Product
                          select x).ToList();

                // if found item rows
                if (ds.Count() > 0)
                {
                    return(HelperCS.ToDataTable(ds));
                }
                else
                {
                    return(new DataTable());
                }
            }
        }
Esempio n. 23
0
        public IHttpActionResult GetListSelected()
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    var order = new List <Order>();

                    order = db.Orders.ToList();

                    var o = order.Select(s => new Order()
                    {
                        Id     = s.Id,
                        FoodId = s.FoodId,
                        Name   = s.Name,
                        Qty    = s.Qty,
                        Price  = s.Price,
                        Total  = s.Total,
                    });

                    return(Json(new
                    {
                        Message = "Success",
                        Result = o,
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = "Error ^^",
                    Code = 400
                }
                           ));
            }
        }        //end selected
Esempio n. 24
0
        private void GetInvoiceReportData(DateTime date, int customer)
        {
            string ReportName = ((KeyValuePair <string, string>)ddlReportName.SelectedItem).Value;

            using (var dailydb = new OrderEntities())
            {
                //var ds1 = (from x in dailydb.vwCustomerDetail
                //           where x.CustomerID == customer
                //           select x).ToList();
                List <GetOrderCustomer_Result> ds1 = null;
                List <GetOrderbyDay_Result>    ds2 = null;
                ds1 = dailydb.GetOrderCustomer(date, customer, "INV").ToList();
                ds2 = dailydb.GetOrderbyDay(date, customer).ToList();
                if (ds1.Count() > 0 && ds2.Count() > 0)
                {
                    string          docid      = (from c in ds1 select(string) c.DocumentID).FirstOrDefault();
                    string          datestring = HelperCS.DateTextThai(date, "TH", "dd MMM yyyy");
                    ReportParameter p1         = new ReportParameter("ReportType", ReportName);
                    //ReportParameter p2 = new ReportParameter("Date", RptDatePicker.Value.ToLongDateString());
                    ReportParameter p2 = new ReportParameter("Date", datestring);
                    ReportParameter p3 = new ReportParameter("BahtText", BahtToText(ds2.Sum(item => item.OrderTotal)));
                    ReportParameter p4 = new ReportParameter("DocumentID", docid);

                    reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4 });
                    CustomerBindingSource.DataSource = null;
                    OrderBindingSource.DataSource    = null;
                    CustomerBindingSource.DataSource = HelperCS.ToDataTable(ds1);
                    OrderBindingSource.DataSource    = HelperCS.ToDataTable(ds2);
                    ReportDataSource rtpsource1 = new ReportDataSource("DataSet1", CustomerBindingSource);
                    ReportDataSource rtpsource2 = new ReportDataSource("DataSet2", OrderBindingSource);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource1);
                    reportViewer1.LocalReport.DataSources.Add(rtpsource2);
                }
                else
                {
                    CustomerBindingSource.DataSource = null;
                    OrderBindingSource.DataSource    = null;
                }
            }
        }
Esempio n. 25
0
        public IHttpActionResult GetList(int categoryId)
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    var food = new List <Food>();

                    food = db.Foods.Where(x => x.CategoryId == categoryId).ToList();

                    var f = food.Select(s => new Food()
                    {
                        Id           = s.Id,
                        Name         = s.Name,
                        RestaurantId = s.RestaurantId,
                        CategoryId   = s.CategoryId,
                        Price        = s.Price,
                        Image        = s.Image
                    });

                    return(Json(new
                    {
                        Message = "Success",
                        Result = f,
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = new List <Food>(),
                    Code = 400
                }
                           ));
            }
        }
Esempio n. 26
0
 private void BindProductData()
 {
     using (var db = new OrderEntities())
     {
         var ds = (from x in db.Product
                   where x.ProductID == productid
                   select x).ToList();
         if (ds.Count > 0)
         {
             txtbProductName.Text            = ds[0].ProductName;
             txtbProductAbbr.Text            = ds[0].ProductAbbr;
             comboProductGroup.SelectedIndex = int.Parse(ds[0].Category.ToString());
             txtbProductPrice.Text           = ds[0].Price.ToString();
             //txtbProductUnit.Text = ds[0].Unit.ToString();
             comboProductCarry.SelectedIndex = int.Parse(ds[0].UnitCarry.ToString());
             comboProductUnit.SelectedIndex  = int.Parse(ds[0].Unit.ToString());
             txtbProductAmount.Text          = ds[0].Amount.ToString();
             txtbProductDescription.Text     = ds[0].Descripiton;
             //bind to control
         }
     }
 }
Esempio n. 27
0
        public IHttpActionResult Login(string username, string password)
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    //var order = new List<Order>();

                    var account = db.Accounts.Where(x => x.Username == username && x.Password == password).FirstOrDefault();

                    //var a=HttpContext.Current.Session["Id"] ="123456" ;

                    var acc = new Account();
                    {
                        acc.Username = account.Username;
                        acc.Password = account.Password;
                    };

                    return(Json(new
                    {
                        Message = "Login Success",
                        Result = acc,
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = "Error ^^",
                    Code = 400
                }
                           ));
            }
        }        //end login
        private void BindCustomerData()
        {
            using (var db = new OrderEntities())
            {
                var ds = (from x in db.Customer
                          where x.CustomerID == customerid
                          select x).ToList();
                if (ds.Count > 0)
                {
                    txtbCustomerCitizenID.Text      = ds[0].CitizenID != null ? ds[0].CitizenID.ToString() : "";
                    txtbCustomerName.Text           = ds[0].CustomerName;
                    txtbCustomerAbbr.Text           = ds[0].CustomerAbbr;
                    comboCustomerZone.SelectedIndex = int.Parse(ds[0].Zone.ToString());
                    txtbCustomerAddress1.Text       = ds[0].Address1;
                    txtbCustomerAddress2.Text       = ds[0].Address2;
                    txtbCustomerPhone.Text          = ds[0].Phone;
                    txtbCustomerDescription.Text    = ds[0].Description;
                    chkCustomerShowPrice.Checked    = ds[0].ShowPrice == true ?true :false;

                    //bind to control
                }
            }
        }
Esempio n. 29
0
        public IHttpActionResult DeleteAll()
        {
            try
            {
                using (var db = new OrderEntities())
                {
                    var order = new List <Order>();
                    order = db.Orders.ToList();

                    if (order != null)
                    {
                        for (int i = 0; i < order.Count; i++)
                        {
                            db.Orders.Remove(order[i]);
                        }
                        db.SaveChanges();
                    }
                    return(Json(new
                    {
                        Message = "Success",
                        Result = "Delete success",
                        Code = 200
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(
                           new
                {
                    Message = ex.Message,
                    Result = "Error ^^",
                    Code = 400
                }
                           ));
            }
        }        //end delete all
Esempio n. 30
0
        protected async void btnSubmit_Click1(object sender, EventArgs e)
        {
            Order NewOrder = new Order();

            NewOrder.AccountingNumber         = txtAccountNumber.Value;
            NewOrder.AddressOnCheck           = txtAddress.Text;
            NewOrder.BankName                 = txtBankName.Text;
            NewOrder.CityOnCheck              = txtCity.Text;
            NewOrder.EMailAddress             = txtEmailAddress.Text;
            NewOrder.NameOnCheck              = txtNameOnCheck.Text;
            NewOrder.PhoneNumber              = fixphone(txtPhoneNumber.Text);
            NewOrder.RoutingNumber            = txtRoutingNumber.Value;
            NewOrder.StateOnCheck             = DropDownListState.Text;
            NewOrder.TotalPrice               = double.Parse(lblTotalPrice.Text);
            NewOrder.TwentyFivesOrdered       = int.Parse(lblTwentyFives.Text);
            NewOrder.TwoHundredFiftiesOrdered = int.Parse(lblTwoHundredFifties.Text);
            NewOrder.OnesOrdered              = int.Parse(lblOnes.Text);
            NewOrder.HundredsOrdered          = int.Parse(lblHundreds.Text);
            NewOrder.FivesOrdered             = int.Parse(lblFives.Text);
            NewOrder.ZipCodeOnCheck           = txtZip.Value;
            NewOrder.TotalCoinsOrdered        = int.Parse(lblTotalCoins.Text);
            NewOrder.CheckNumber              = txtCheckNumber.Text;
            NewOrder.TimeStamp                = DateTime.Now;
            NewOrder.Affiliate                = af;

            CoinsAvailableAfterSale(NewOrder);

            string ClientID    = WebConfigurationManager.AppSettings["GreenPayID"];
            string APIPassword = WebConfigurationManager.AppSettings["GreenPayAPIPassword"];

            GreenPayECheck.eCheckSoapClient client      = new GreenPayECheck.eCheckSoapClient();
            GreenPayECheck.DraftResult      DraftResult = new GreenPayECheck.DraftResult();

            if (NewOrder.AccountingNumber == "5555555555")
            {
                if (NewOrder.RoutingNumber == "1")
                {
                    DraftResult = testSuccess();
                }
                else
                {
                    DraftResult = testFailure();
                }
            }
            else
            {
                DraftResult = client.OneTimeDraftRTV(ClientID, APIPassword, NewOrder.NameOnCheck, NewOrder.EMailAddress, NewOrder.PhoneNumber, "", NewOrder.AddressOnCheck, "", NewOrder.CityOnCheck,
                                                     NewOrder.StateOnCheck, NewOrder.ZipCodeOnCheck, "US", NewOrder.RoutingNumber, NewOrder.AccountingNumber, NewOrder.BankName, "", NewOrder.TotalPrice.ToString(),
                                                     DateTime.Now.ToShortDateString(), NewOrder.CheckNumber, "", "");
            }

            NewOrder.CheckID = DraftResult.Check_ID;
            NewOrder.VerificationResultCode = DraftResult.VerifyResult;
            NewOrder.VerificationResultDesc = DraftResult.VerifyResultDescription;

            OrderEntities oe = new OrderEntities();

            oe.Orders.Add(NewOrder);
            oe.SaveChanges();

            if (DraftResult.VerifyResult == "0")
            {
                await FillOrder(NewOrder);
            }
            else
            {
                Response.Redirect("OrderFailure.aspx");
            }

            int x = 0;
        }