예제 #1
0
        private void addShipper(HttpContext context, int intID)
        {
            string output = "";

            try
            {
                var JsonStr = context.Request["models"];
                List <clsShipper> Shippers = JsonConvert.DeserializeObject <List <clsShipper> >(JsonStr);
                using (ERP_CMSEntities cntx = new ERP_CMSEntities())
                {
                    string shipperContact1 = Shippers[0].Contact1;
                    var    obj             = (from tbl in cntx.Shippers
                                              where tbl.IsDeleted == false && tbl.Contact1 == shipperContact1
                                              select tbl).FirstOrDefault();

                    if (obj == null)
                    {
                        var objShipper = new ERP_CMS.DB_Code.Shipper()
                        {
                            Shipper_Name    = Shippers[0].Shipper_Name,
                            Shipper_Address = Shippers[0].Shipper_Address,
                            Shipper_Email   = Shippers[0].Shipper_Email,
                            Contact1        = Shippers[0].Contact1,
                            Contact2        = Shippers[0].Contact2,
                            IsDeleted       = false,
                            InsertedDate    = DateTime.Now,
                            InsertedBy      = userID
                        };
                        cntx.Shippers.Add(objShipper);
                        cntx.SaveChanges();

                        context.Response.ContentType = "application/json; charset=utf-8";
                        context.Response.Write(JsonStr);
                    }
                    else
                    {
                        context.Response.ContentType = "application/json; charset=utf-8";
                        Newtonsoft.Json.Linq.JObject objErr = new Newtonsoft.Json.Linq.JObject();
                        objErr.Add("Errors", "Shipper Already Exists!");
                        context.Response.Write(objErr.ToString());
                    }
                }
            }


            catch (Exception ex)
            {
                context.Response.ContentType = "application/json; charset=utf-8";
                Newtonsoft.Json.Linq.JObject objErr = new Newtonsoft.Json.Linq.JObject();
                objErr.Add("Errors", ex.Message);
                context.Response.Write(objErr.ToString());
            }
        }
예제 #2
0
        private void deleteShipper(HttpContext context, int intID)
        {
            string output = "";

            try
            {
                var JsonStr = context.Request["models"];
                List <clsShipper> Shippers = JsonConvert.DeserializeObject <List <clsShipper> >(JsonStr);

                using (ERP_CMSEntities cntx = new ERP_CMSEntities())
                {
                    var objShipper = new ERP_CMS.DB_Code.Shipper()
                    {
                        ShipperID = Convert.ToInt32(Shippers[0].ShipperID)
                    };
                    //objAgentTypes.DeletedBy = userID;
                    // Dim objBrands = New PortalModel.Brands With {.BrandID = intID}
                    cntx.Shippers.Attach(objShipper);
                    objShipper.IsDeleted   = true;
                    objShipper.DeletedBy   = userID;
                    objShipper.DeletedDate = DateTime.Now;
                    // cntx.Brands.DeleteObject(objBrands)
                    cntx.SaveChanges();
                }


                context.Response.ContentType = "application/json; charset=utf-8";
                context.Response.Write(JsonStr);
            }
            catch (Exception ex)
            {
                context.Response.ContentType = "application/json; charset=utf-8";
                Newtonsoft.Json.Linq.JObject objErr = new Newtonsoft.Json.Linq.JObject();
                objErr.Add("Errors", ex.Message);
                context.Response.Write(objErr.ToString());
            }
        }