//删除数据
        protected void notarizeDelete(object sender, EventArgs e)
        {
            int loginid = getLoginUserID();

            if (loginid == -1)
            {
                return;
            }
            int vendor_id = -1;

            try
            {
                vendor_id = int.Parse(vendor_id_delete.Value.ToString());
            }
            catch (Exception ex)
            {
                PageUtil.showToast(this, "数据异常,删除失败!");
                return;
            }
            SupplierDC supplierDC = new SupplierDC();

            if (supplierDC.deleteSupplier(vendor_id))
            {
                PageUtil.showToast(this, "数据删除成功!");
                string vendor_name1 = vendor_name_id.Value.Trim();
                string vendor_key1  = vendor_key_id.Value.Trim();
                Line_Repeater.DataSource = supplierDC.getSupplierBySome(vendor_name1, vendor_key1);
                Line_Repeater.DataBind();
            }
            else
            {
                PageUtil.showToast(this, "数据删除失败!");
            }
        }
Exemplo n.º 2
0
        //Where Used: SupplierProduct
        public List <Supplier> IsValidClientDetailSupplierProduct(int clientDetailId, int productId, string supplierCode)
        {
            SupplierDC db = new SupplierDC(Settings.getConnectionString());

            var result = from n in db.Suppliers
                         where ((n.ProductId == productId) && (n.SupplierCode.Equals(supplierCode)))
                         select
                         n;

            return(result.ToList());
        }
Exemplo n.º 3
0
        //Where Used: Client-Side Validation of Supplier/Product combos
        public List <Supplier> IsValidSupplierName(string supplierName)
        {
            SupplierDC         db = new SupplierDC(Settings.getConnectionString());
            SupplierRepository supplierRepository = new SupplierRepository();

            var result = from n in db.Suppliers
                         where (n.SupplierName.Equals(supplierName))
                         select
                         n;

            return(result.ToList());
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            SupplierDC supplierDC = new SupplierDC();

            List <string> list = new List <string>();

            list = supplierDC.getAllVendor_key();

            string json = toJson(list);

            context.Response.ContentType = "text/plain";

            context.Response.Write(json);
        }
        //查询
        protected void selectSome(object sender, EventArgs e)
        {
            string vendor_name = vendor_name_id.Value.Trim();
            string vendor_key  = vendor_key_id.Value.Trim();

            SupplierDC supplierDC = new SupplierDC();
            DataSet    ds         = supplierDC.getSupplierBySome(vendor_name, vendor_key);

            if (ds == null)
            {
                PageUtil.showToast(this, "未查询到数据!");
                return;
            }
            Line_Repeater.DataSource = ds;
            Line_Repeater.DataBind();
        }
        //Eager Loading: return a singleton value
        public JsonResult EagerLoadingSingletonValue()
        {
            var context = new OrdersContext();

            var supplier = context.Suppliers.Include(s => s.Products).First();

            //check SQL Profiler here
            var supplierDC = new SupplierDC
            {
                SupplierId  = supplier.SupplierId,
                CompanyName = supplier.CompanyName,
                Products    = supplier.Products.Select(p => new ProductDC
                {
                    ProductId   = p.ProductId,
                    ProductName = p.ProductName
                })
            };

            //check SQL Profiler here
            return(Json(supplierDC, JsonRequestBehavior.AllowGet));
        }
        //Find() method Versus FirstOrDefault() method
        public JsonResult FindVersusFirstOrDefault()
        {
            var context = new OrdersContext();

            //Using Find()
            var supplierX1 = context.Suppliers.Find(1);             // it will be cached
            var supplierX2 = context.Suppliers.Find(1);

            var supplierXDC = new SupplierDC
            {
                SupplierId  = supplierX2.SupplierId,
                CompanyName = supplierX2.CompanyName,
                Products    = supplierX2.Products.Select(p => new ProductDC
                {
                    ProductId   = p.ProductId,
                    ProductName = p.ProductName
                })
            };


            //Using FirstOrDefault()
            var supplierY = context.Suppliers.Include(x => x.Products).FirstOrDefault(x => x.SupplierId == 1);

            var supplierYDC = new SupplierDC
            {
                SupplierId  = supplierY.SupplierId,
                CompanyName = supplierY.CompanyName,
                Products    = supplierX2.Products.Select(p => new ProductDC
                {
                    ProductId   = p.ProductId,
                    ProductName = p.ProductName
                })
            };

            return(Json(new
            {
                supplierXDC,
                supplierYDC
            }, JsonRequestBehavior.AllowGet));
        }
        //更新数据
        protected void notarizeUpdate(object sender, EventArgs e)
        {
            int loginid = getLoginUserID();

            if (loginid == -1)
            {
                return;
            }
            string vendor_id   = vendor_id_update.Value.Trim();
            string vendor_name = vendor_name_update.Value.Trim();
            string vendor_key  = vendor_key_update.Value.Trim();

            if (!checkData(vendor_name, vendor_key))
            {
                return;
            }
            SupplierDC supplierDC = new SupplierDC();
            DataSet    search_ds  = supplierDC.getSupplierByNameAndKeyAndId(vendor_id, vendor_name, vendor_key);

            //如过大于2,则数据库中已存在该name和key,否则 就可以更新
            if (search_ds != null && search_ds.Tables[0].Rows.Count > 0)
            {
                PageUtil.showToast(this, "供应商名称或者供应商代码已存在!");
                return;
            }
            if (supplierDC.updateSupplier(vendor_id, vendor_name, loginid, vendor_key, DateTime.Now))
            {
                PageUtil.showToast(this, "数据更新成功!");
                string vendor_name1 = vendor_name_id.Value.Trim();
                string vendor_key1  = vendor_key_id.Value.Trim();
                Line_Repeater.DataSource = supplierDC.getSupplierBySome(vendor_name1, vendor_key1);
                Line_Repeater.DataBind();
            }
            else
            {
                PageUtil.showToast(this, "数据更新失败!");
            }
        }
        //Lazy Loading: return a singleton value
        public JsonResult LazyLoadingSingletonValue()
        {
            var context = new OrdersContext();

            //Queries that return a singleton value are executed immediately
            //e.g: Average, Count, First, Single, and Max
            var supplier = context.Suppliers.First();

            //check SQL Profiler here
            var supplierDC = new SupplierDC
            {
                SupplierId  = supplier.SupplierId,
                CompanyName = supplier.CompanyName,
                Products    = supplier.Products.Select(p => new ProductDC
                {
                    ProductId   = p.ProductId,
                    ProductName = p.ProductName
                })
            };

            //check SQL Profiler here
            return(Json(supplierDC, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        //插入数据
        protected void notarizeInsert(object sender, EventArgs e)
        {
            int loginid = getLoginUserID();

            if (loginid == -1)
            {
                return;
            }
            string vendor_name = vendor_name_insert.Value.Trim();
            string vendor_key  = vendor_key_insert.Value.Trim();

            if (!checkData(vendor_name, vendor_key))
            {
                return;
            }
            SupplierDC supplierDC = new SupplierDC();
            DataSet    search_ds  = supplierDC.getSupplierByNameAndKey(vendor_name, vendor_key);

            if (search_ds != null && search_ds.Tables[0].Rows.Count > 0)
            {
                PageUtil.showToast(this, "供应商名称或者供应商代码已存在!");
                return;
            }
            else if (supplierDC.insertSupplier(vendor_name, loginid, vendor_key, DateTime.Now))
            {
                PageUtil.showToast(this, "数据插入成功!");
                vendor_name_insert.Value = "";
                vendor_key_insert.Value  = "";
                Line_Repeater.DataSource = supplierDC.getSupplierBySome("", "");
                Line_Repeater.DataBind();
            }
            else
            {
                PageUtil.showToast(this, "数据插入失败!");
            }
        }