Пример #1
0
        private int getListXuatTheoThoiGian(HttpContext context)
        {
            try
            {
                string From_Date = context.Request.QueryString["From_Date"];
                string To_Date   = context.Request.QueryString["To_Date"];

                int check = checkDateTime(From_Date, To_Date);

                if (check != 0)
                {
                    return(check);
                }

                DateTime FromDate = DateTime.ParseExact(From_Date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime ToDate   = DateTime.ParseExact(To_Date, "dd/MM/yyyy", CultureInfo.InvariantCulture);

                var total      = 0;
                var listResult = new List <Chi_Tiet_Don_Hang>();
                // Lấy ra list đơn hàng đã cập nhât bằng chứng thanh toán
                var listDonHang        = db.DON_HANGs.Where(p => p.Bang_Chung_Thanh_Toan != null && p.Ngay_Dat <= ToDate && p.Ngay_Dat >= FromDate);
                var listChiTietDonHang = db.CHI_TIET_DON_HANGs.Join(listDonHang, ct => ct.Ma_Don_Hang, dh => dh.Ma_Don_Hang,
                                                                    (ct, dh) => new { ct, dh });

                foreach (var item in listChiTietDonHang)
                {
                    var ctdh = new Chi_Tiet_Don_Hang();

                    ctdh.Ma_Chi_Tiet_DH = item.ct.Ma_Chi_Tiet_DH;
                    ctdh.Ma_Don_Hang    = item.ct.Ma_Don_Hang;
                    ctdh.So_Luong_Xuat  = item.ct.So_Luong_Xuat;
                    ctdh.Ma_Trai_Cay    = item.ct.Ma_Trai_Cay;
                    ctdh.Don_Gia_Xuat   = item.ct.Don_Gia_Xuat;
                    ctdh.Tong_Tien_Xuat = item.ct.So_Luong_Xuat * item.ct.Don_Gia_Xuat;
                    ctdh.Thoi_Gian      = item.dh.Ngay_Dat;;
                    //Chi tiet trai cay
                    var traiCay = db.TRAI_CAYs.Where(p => p.Ma_Trai_Cay == item.ct.Ma_Trai_Cay).FirstOrDefault();

                    ctdh.Ten_Trai_Cay = traiCay.Ten_Trai_Cay;
                    ctdh.Don_Vi_Tinh  = traiCay.Don_Vi_Tinh;
                    ctdh.Xuat_Xu      = traiCay.Xuat_Xu;


                    listResult.Add(ctdh);
                }

                object_Response.Status_Code = 0;
                object_Response.Status_Text = total.ToString();
                object_Response.Data        = listResult;

                context.Response.ContentType = "text/json";
                context.Response.Write(JsonConvert.SerializeObject(object_Response));
                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(-1);
            }
        }
Пример #2
0
        private int getListXuat(HttpContext context)
        {
            try
            {
                long total      = 0;
                var  listResult = new List <Chi_Tiet_Don_Hang>();

                // Lấy ra list đơn hàng đã cập nhât bằng chứng thanh toán
                var listDonHang        = db.DON_HANGs.Where(p => p.Bang_Chung_Thanh_Toan != null);
                var listChiTietDonHang = db.CHI_TIET_DON_HANGs.Join(listDonHang, ct => ct.Ma_Don_Hang, dh => dh.Ma_Don_Hang,
                                                                    (ct, dh) => new { ct, dh });

                foreach (var item in listChiTietDonHang)
                {
                    var ctdh = new Chi_Tiet_Don_Hang();

                    ctdh.Ma_Chi_Tiet_DH = item.ct.Ma_Chi_Tiet_DH;
                    ctdh.Ma_Don_Hang    = item.ct.Ma_Don_Hang;
                    ctdh.Thoi_Gian      = item.dh.Ngay_Dat;;
                    ctdh.So_Luong_Xuat  = item.ct.So_Luong_Xuat;
                    ctdh.Ma_Trai_Cay    = item.ct.Ma_Trai_Cay;
                    ctdh.Don_Gia_Xuat   = item.ct.Don_Gia_Xuat;
                    ctdh.Tong_Tien_Xuat = item.ct.So_Luong_Xuat * item.ct.Don_Gia_Xuat;
                    //Chi tiet trai cay
                    var traiCay = db.TRAI_CAYs.Where(p => p.Ma_Trai_Cay == item.ct.Ma_Trai_Cay).FirstOrDefault();

                    ctdh.Ten_Trai_Cay = traiCay.Ten_Trai_Cay;
                    ctdh.Don_Vi_Tinh  = traiCay.Don_Vi_Tinh;
                    ctdh.Xuat_Xu      = traiCay.Xuat_Xu;


                    listResult.Add(ctdh);
                }

                object_Response.Status_Code = 0;
                object_Response.Status_Text = total.ToString();
                object_Response.Data        = listResult;

                context.Response.ContentType = "text/json";
                context.Response.Write(JsonConvert.SerializeObject(object_Response));
                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(-1);
            }
        }
Пример #3
0
        private int getChiTietDonHangByID(HttpContext context)
        {
            try
            {
                string maDonHang = context.Request.QueryString["MaDonHang"];

                if (maDonHang.Length == 0)
                {
                    return(1);
                }
                var listChiTiet = db.CHI_TIET_DON_HANGs.Where(p => p.Ma_Don_Hang == maDonHang);
                var listResult  = new List <Chi_Tiet_Don_Hang>();
                Chi_Tiet_Don_Hang ctdh;
                foreach (CHI_TIET_DON_HANG item in listChiTiet)
                {
                    ctdh = new Chi_Tiet_Don_Hang();
                    ctdh.Ma_Chi_Tiet_DH = item.Ma_Chi_Tiet_DH;
                    ctdh.Ma_Don_Hang    = item.Ma_Don_Hang;
                    ctdh.So_Luong_Xuat  = item.So_Luong_Xuat;
                    ctdh.Don_Gia_Xuat   = item.Don_Gia_Xuat;
                    ctdh.Ma_Trai_Cay    = item.Ma_Trai_Cay;
                    ctdh.Tong_Tien_Xuat = item.So_Luong_Xuat * item.Don_Gia_Xuat;

                    var dh = db.DON_HANGs.Where(p => p.Ma_Don_Hang == maDonHang).FirstOrDefault();
                    ctdh.Thoi_Gian = dh.Ngay_Dat;

                    var tc = db.TRAI_CAYs.Where(p => p.Ma_Trai_Cay == item.Ma_Trai_Cay).FirstOrDefault();
                    ctdh.Ten_Trai_Cay = tc.Ten_Trai_Cay;
                    ctdh.Xuat_Xu      = tc.Xuat_Xu;
                    ctdh.Don_Vi_Tinh  = tc.Don_Vi_Tinh;

                    listResult.Add(ctdh);
                }
                object_Response.Status_Code = 0;
                object_Response.Status_Text = "Get list chi tiet đơn hàng thành công";
                object_Response.Data        = listResult;

                context.Response.ContentType = "text/json";
                context.Response.Write(JsonConvert.SerializeObject(object_Response));
                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(-1);
            }
        }