Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var db = new UITestEntities())
            {
                if (!IsPostBack)
                {
                    var sup = from c in db.Supliers
                              orderby c.FirstName
                              select new { c.ID, c.FirstName };

                    DropDownList1.DataValueField = "ID";
                    DropDownList1.DataTextField  = "FirstName";
                    DropDownList1.DataSource     = sup.ToList();


                    var good = from c in db.PurchaseGoods
                               orderby c.Item
                               select new { c.ID, c.Item };

                    DropDownList2.DataValueField = "ID";
                    DropDownList2.DataTextField  = "Item";
                    DropDownList2.DataSource     = good.ToList();


                    DataBind();
                    DropDownList2.Items.Insert(0, "Select a Item");
                    DropDownList1.Items.Insert(0, "Select a Suplier");
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("Error_404.aspx");
            }
            int id = Int32.Parse(Request.QueryString["id"]);

            using (var db = new UITestEntities())
            {
                Buyer buyer = db.Buyers.Find(id);
                if (buyer == null)
                {
                }
                else
                {
                    fname.Text     = buyer.FirstName;
                    lname.Text     = buyer.LastName;
                    address.Text   = buyer.Address;
                    country.Text   = buyer.Country;
                    telephone.Text = buyer.Telephone;
                    fax.Text       = buyer.Fax;
                    email.Text     = buyer.Email;
                    remarks.Text   = buyer.Remarks;
                }
            }
        }
Exemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("Error_404.aspx");
            }
            int id = Int32.Parse(Request.QueryString["id"]);

            using (var db = new UITestEntities())
            {
                Buyer buyer = db.Buyers.Single(u => u.ID == id);

                buyer.FirstName = fname.Text;
                buyer.LastName  = lname.Text;
                buyer.Address   = address.Text;
                buyer.Country   = country.Text;
                buyer.Telephone = telephone.Text;
                buyer.Fax       = fax.Text;
                buyer.Email     = email.Text;
                buyer.Remarks   = remarks.Text;

                db.SaveChanges();
            }

            Response.Redirect("Search_Buyer.aspx");
        }
Exemplo n.º 4
0
 public static void Save_User(User usr)
 {
     using (var db = new UITestEntities())
     {
         db.Users.Add(usr);
     }
 }
Exemplo n.º 5
0
        protected void Submit(object sender, EventArgs e)
        {
            try
            {
                UITestEntities db = new UITestEntities();

                Suplier sup = new Suplier
                {
                    FirstName = fname.Text.ToString(),
                    LastName  = lname.Text.ToString(),
                    Address   = address.Text.ToString(),
                    Telephone = telephone.Text.ToString(),
                    Fax       = fax.Text.ToString(),
                    Email     = email.Text.ToString(),
                    Remarks   = remarks.Text.ToString()
                };

                db.Supliers.Add(sup);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 6
0
        public static string LoadTable()
        {
            JavaScriptSerializer TheSerializer = new JavaScriptSerializer();

            using (var db = new UITestEntities())
            {
                var data    = db.Supliers.OrderBy(o => o.ID).ToList();
                var TheJson = TheSerializer.Serialize(data);
                return(TheJson);
            }
        }
Exemplo n.º 7
0
        public static string LoadTypeDropDown(int id)
        {
            //edit this --------------------------------------------------------------------------------------------------------------------------
            using (var db = new UITestEntities())
            {
                var good = from c in db.PurchaseGoods
                           orderby c.Item
                           select new { c.ID, c.Item };

                return(JsonConvert.SerializeObject(good.ToList()));
            }
        }
Exemplo n.º 8
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (var db = new UITestEntities())
     {
         User usr = new User
         {
             Username = Username.Text,
             Password = Password.Text,
             Type     = Type.Text
         };
     }
 }
        public static string Search(string F)
        {
            string Fname = F;

            using (UITestEntities db = new UITestEntities())
            {
                if (Fname != "")
                {
                    var buyer = from c in db.Supliers
                                where c.FirstName.Contains(Fname)
                                select c;
                    return(JsonConvert.SerializeObject(buyer));
                }
                else
                {
                    var buyer = db.Supliers.ToList();
                    return(JsonConvert.SerializeObject(buyer));
                }
            }
        }
        protected void BuyerSaveBtn_Click(object sender, EventArgs e)
        {
            var buyer = new Buyer();

            using (UITestEntities DB = new UITestEntities())
            {
                try
                {
                    buyer.ID        = 1;
                    buyer.FirstName = fname.Text;
                    buyer.LastName  = lname.Text;
                    buyer.Address   = address.Text;
                    buyer.Country   = country.Text;
                    buyer.Telephone = telephone.Text;
                    buyer.Fax       = fax.Text;
                    buyer.Email     = email.Text;
                    buyer.Remarks   = remarks.Text;


                    DB.Buyers.Add(buyer);
                    DB.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
        }
Exemplo n.º 11
0
 private void GreetingBtn_Click(Object sender, EventArgs e)
 {
     try
     {
         using (UITestEntities ctx = new UITestEntities())
         {
             ctx.Database.Connection.Open();
             var usr = ctx.Users.Where(o => o.Username == txtusername.Text.ToString()).ToList <User>();
             if (usr.Count == 0)
             {
                 Label1.Text = "errrroooo";
             }
             else
             {
                 if (usr[0].Password == txtpassword.Text)
                 {
                     if (usr[0].Type.Equals("Admin     "))
                     {
                         Session["UserName"] = usr[0].Username;
                         Label1.Text         = "Pleace Wait";
                         Response.Redirect("Home.aspx", false);
                     }
                     else
                     {
                         Response.Redirect("");
                     }
                 }
                 else
                 {
                     Label1.Text = "asfq";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Response.Redirect("Error_404.aspx");
         throw;
     }
     // Display the greeting label text.
 }
Exemplo n.º 12
0
        public static string Search(string F, string L, string C)
        {
            string Fname   = F;
            string Lname   = L;
            string Country = C;

            using (UITestEntities db = new UITestEntities())
            {
                //var buyerL = db.Buyers.Where(o => o.LastName == Lname);
                //var buyerC = db.Buyers.Where(o => o.Country == Country);

                if (Fname != "" && Lname != "" && Country != "")
                {
                    var buyer = db.Buyers.Where(o => o.FirstName == Fname && o.LastName == Lname && o.Country == Country).ToList();
                    //var buyer = from c in db.Buyers
                    //            where c.FirstName.Contains(Fname)
                    //            select c;
                    return(JsonConvert.SerializeObject(buyer));
                }
                else if (Fname != "" && Lname != "")
                {
                    var buyer = db.Buyers.Where(o => o.FirstName == Fname && o.LastName == Lname).ToList();
                    return(JsonConvert.SerializeObject(buyer));
                }
                else if (Fname != "" && Country != "")
                {
                    var buyer = db.Buyers.Where(o => o.FirstName == Fname && o.Country == Country).ToList();
                    return(JsonConvert.SerializeObject(buyer));
                }
                else if (Lname != "" && Country != "")
                {
                    var buyer = db.Buyers.Where(o => o.LastName == Lname && o.Country == Country).ToList();
                    return(JsonConvert.SerializeObject(buyer));
                }
                else if (Fname != "")
                {
                    //var buyer = db.Buyers.Where(o =>o.FirstName == Fname).ToList();
                    var buyer = from c in db.Buyers
                                where c.FirstName.Contains(Fname)
                                select c;
                    return(JsonConvert.SerializeObject(buyer));
                }
                else if (Lname != "")
                {
                    //var buyer = db.Buyers.Where(o => o.LastName == Lname).ToList();
                    var buyer = from c in db.Buyers
                                where c.LastName.Contains(Lname)
                                select c;
                    return(JsonConvert.SerializeObject(buyer));
                }
                else if (Country != "")
                {
                    //var buyer = db.Buyers.Where(o => o.Country == Country).ToList();
                    var buyer = from c in db.Buyers
                                where c.Country.Contains(Country)
                                select c;
                    return(JsonConvert.SerializeObject(buyer));
                }
                else
                {
                    var buyer = db.Buyers.ToList();
                    return(JsonConvert.SerializeObject(buyer));
                }
            }
        }