Beispiel #1
0
        public virtual int CompareTo(HealthRecord other)
        {
            // не сравниваем содержимое записи
            if (other == null)
            {
                return(-1);
            }

            int res = Holder.CompareTo(other.Holder);

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

            res = Ord.CompareTo(other.Ord);
            if (res != 0)
            {
                return(res);
            }

            res = UpdatedAt.CompareTo(other.UpdatedAt);
            if (res != 0)
            {
                return(res);
            }

            res = Doctor.CompareTo(other.Doctor);
            return(res);
        }
Beispiel #2
0
        private void btnAddOrder_Click(object sender, EventArgs e)
        {
            if (commet.Text != "")
            {
                Ord o = new Ord(commet.Text, User.getInstance(), film);


                List <Ord> os = films.Ords.ToList();

                foreach (Ord ord in os)
                {
                    if ((ord.IdFilm == o.IdFilm) && (ord.IdUser == o.IdUser))
                    {
                        DialogManager.showDialogError("У вас уже имеется заказ на этот фильм!", "");
                        return;
                    }
                }


                films.Ords.Add(o);
                films.SaveChanges();

                DialogManager.showDialogInfo("Успешный заказ!", "");
            }
            else
            {
                DialogManager.showDialogError("Введите пожалуйста количество требуемых мест", "");
            }
        }
Beispiel #3
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txtOrderCity.Text))
        {
            Ord o = new Ord();
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                o.OrderID = Convert.ToInt32(Request.QueryString["id"].ToString());
            }
            else
            {
                o.OrderID = 0;
            }
            o.UserID = Convert.ToInt32(txtUserID.Text);
            o.StatusID = Convert.ToInt32(txtStatusID.Text);
            o.OrderDate = Convert.ToDateTime(txtOrderDate.Text);
            o.OrderAdd1 = txtOrderAddress1.Text;
            o.OrderAdd2 = txtOrderAddress2.Text;
            o.OrderCity = txtOrderCity.Text;
            o.StateID = Convert.ToInt32(txtStateID.Text);
            o.OrderZip = txtOrderZip.Text;
            o.OrderLastUpdate = Convert.ToDateTime(txtOrderLastUpdate.Text);

            if (Ord.Save(o))
            {
                Response.Redirect("~/Orders.aspx");
            }
            else
            {
                lblError.Text = "Error saving record.";
            }

        }
    }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "Id,OrdId,DishId,Status")] Meals meals)
        {
            if (ModelState.IsValid)
            {

                Ord CurrentOrder = db.Ord.Find(meals.OrdId);
                if (CurrentOrder != null) {

                ViewBag.IsOrdClosed = false;
                if ( CurrentOrder.TimeEnd != null)
                    {
                        db.Meals.Add(meals);
                        CurrentOrder.TotalCost += db.Dish.Find(meals.DishId).Price;
                        db.Entry(CurrentOrder).State = EntityState.Modified;
                        db.SaveChanges();
                        ViewBag.IsOrdClosed = true;
                    }
            }
                //return RedirectToAction("Create", "Meals", new { ordId = meals.OrdId });
            }
            IEnumerable<Meals> MenuMeals = db.Meals.Where(u => u.OrdId == meals.OrdId).AsEnumerable();
            ViewBag.dishes = MenuMeals;
            ViewBag.DishId = new SelectList(db.Dish, "Id", "Name", meals.DishId);
            return View(meals);
        }
Beispiel #5
0
        /// <summary>
        /// Generate range of es with step of one
        /// </summary>
        /// <param name="from">Starting element</param>
        /// <param name="to">The last element in a sequence</param>
        public static IEnumerable <int> EnumFromTo(int from, int to)
        {
            var alg = AInt32.Class;

            var direction = alg.Compare(to, from);

            if (direction.IsEq())
            {
                yield return(from);

                yield break;
            }

            var increment = direction.Case(-1, 0, 1);

            var current = from;

            while (true)
            {
                yield return(current);

                if (Ord.Compare(alg.Compare(to, current), direction).IsNeq())
                {
                    yield break;
                }

                current += increment;
            }
        }
Beispiel #6
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txtOrderCity.Text))
        {
            Ord o = new Ord();
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                o.OrderID = Convert.ToInt32(Request.QueryString["id"].ToString());
            }
            else
            {
                o.OrderID = 0;
            }
            o.UserID          = Convert.ToInt32(txtUserID.Text);
            o.StatusID        = Convert.ToInt32(txtStatusID.Text);
            o.OrderDate       = Convert.ToDateTime(txtOrderDate.Text);
            o.OrderAdd1       = txtOrderAddress1.Text;
            o.OrderAdd2       = txtOrderAddress2.Text;
            o.OrderCity       = txtOrderCity.Text;
            o.StateID         = Convert.ToInt32(txtStateID.Text);
            o.OrderZip        = txtOrderZip.Text;
            o.OrderLastUpdate = Convert.ToDateTime(txtOrderLastUpdate.Text);


            if (Ord.Save(o))
            {
                Response.Redirect("~/Orders.aspx");
            }
            else
            {
                lblError.Text = "Error saving record.";
            }
        }
    }
Beispiel #7
0
    public static Ord Fetch(int id)
    {
        Ord o = new Ord();
        //connection object - ConfigurationManager namespace allows for runtime
        //access to web.config setting, specifically connection strings and key values
        SqlConnection cn = new
                           SqlConnection(ConfigurationManager.ConnectionStrings["cs"].ConnectionString);
        //command object is for direct interface with database
        //this constructor uses 2 arguments, first is name of stored procedure,
        //2nd is connection object
        SqlCommand cmd = new SqlCommand("spGetOrderByID", cn);
        //Create datatable to hold result set
        DataTable dt = new DataTable();

        // Mark the Command as a Stored Procedure
        //command type is an enumeration: Stored procedure, text(embedded SQL) or table direct
        cmd.CommandType = CommandType.StoredProcedure;

        // Add Parameters to Stored Procedure
        cmd.Parameters.Add("@OrderID", SqlDbType.Int).Value = id;

        // Open the database connection and execute the command
        try
        {
            //opens connection to database, most failures happen here
            //check connection string for proper settings
            cn.Open();
            //data adapter object is trasport link between data source and
            //data destination
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            //fill method, for multiple tables use dataset
            da.Fill(dt);
        }
        catch (Exception exc)
        {
            //just put here to make debugging easier, can look at error directly
            exc.ToString();
        }
        finally
        {
            //must always close connections
            cn.Close();
        }

        // Return the dataset
        if (dt.Rows.Count > 0)
        {
            o.OrderID         = Convert.ToInt32(dt.Rows[0]["OrderID"].ToString());
            o.UserID          = Convert.ToInt32(dt.Rows[0]["UserID"].ToString());
            o.StatusID        = Convert.ToInt32(dt.Rows[0]["StatusID"].ToString());
            o.OrderDate       = Convert.ToDateTime(dt.Rows[0]["OrderDate"].ToString());
            o.OrderAdd1       = dt.Rows[0]["OrderAdd1"].ToString();
            o.OrderAdd2       = dt.Rows[0]["OrderAdd2"].ToString();
            o.OrderCity       = dt.Rows[0]["OrderCity"].ToString();
            o.StateID         = Convert.ToInt32(dt.Rows[0]["StateID"].ToString());
            o.OrderZip        = dt.Rows[0]["OrderZip"].ToString();
            o.OrderLastUpdate = Convert.ToDateTime(dt.Rows[0]["OrderLastUpdate"].ToString());
        }
        return(o);
    }
Beispiel #8
0
 private void SortInsertListFlipped()
 {
     if (insertListOrd != Ord.ORD_21)
     {
         PackedIntPairs.SortFlipped(insertList, insertCount);
         insertListOrd = Ord.ORD_21;
     }
 }
Beispiel #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Ord ord = db.Ord.Find(id);

            db.Ord.Remove(ord);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #10
0
        //////////////////////////////////////////////////////////////////////////////

        public void Reset()
        {
            if (hasDeletes)
            {
                hasDeletes = false;

                if (clear)
                {
                    clear = false;
                }

                if (deleteCount > 0)
                {
                    deleteCount        = 0;
                    deleteListIsSorted = false;
                    if (deleteList.Length > 1024)
                    {
                        deleteList = Array.emptyLongArray;
                    }
                }

                if (delete1Count > 0)
                {
                    delete1Count        = 0;
                    delete1ListIsSorted = false;
                    if (delete1List.Length > 1024)
                    {
                        delete1List = Array.emptyIntArray;
                    }
                }

                if (delete2Count > 0)
                {
                    delete2Count        = 0;
                    delete1ListIsSorted = false;
                    if (delete2List.Length > 1024)
                    {
                        delete2List = Array.emptyIntArray;
                    }
                }

                if (buffer.Length > 1024)
                {
                    buffer = Array.emptyIntArray;
                }
            }

            if (insertCount > 0)
            {
                insertCount   = 0;
                insertListOrd = Ord.ORD_NONE;
                if (insertList.Length > 1024)
                {
                    insertList = Array.emptyLongArray;
                }
            }
        }
Beispiel #11
0
        //////////////////////////////////////////////////////////////////////////////

        private void SortInsertList()
        {
            if (insertListOrd != Ord.ORD_12)
            {
                Debug.Assert(insertListOrd == Ord.ORD_NONE);
                PackedIntPairs.Sort(insertList, insertCount);
                insertListOrd = Ord.ORD_12;
            }
        }
Beispiel #12
0
        public ActionResult CloseOrd(int id)
        {
            Ord ord = db.Ord.Find(id);

            ord.TimeEnd         = DateTime.Now;
            db.Entry(ord).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #13
0
 public void Prepare312()
 {
     if (deleteCount != 0 | insertCount != 0)
     {
         if (currOrd != Ord.ORD_312)
         {
             Ints312.Sort(deleteList, deleteCount);
             Ints312.Sort(insertList, insertCount);
             currOrd = Ord.ORD_312;
         }
     }
 }
Beispiel #14
0
        //////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////

        public void Prepare123()
        {
            if (deleteCount != 0 | insertCount != 0)
            {
                Debug.Assert(currOrd == Ord.ORD_NONE | currOrd == Ord.ORD_123);
                if (currOrd != Ord.ORD_123)
                {
                    Ints123.Sort(deleteList, deleteCount);
                    Ints123.Sort(insertList, insertCount);
                    currOrd = Ord.ORD_123;
                }
            }
        }
Beispiel #15
0
 public void Prepare231()
 {
     if (deleteCount != 0 | insertCount != 0)
     {
         Debug.Assert(currOrd != Ord.ORD_312);
         if (currOrd != Ord.ORD_231)
         {
             Ints231.Sort(deleteList, deleteCount);
             Ints231.Sort(insertList, insertCount);
             currOrd = Ord.ORD_231;
         }
     }
 }
    public List <Ord> AnnoteraMening(string mening)
    {
        List <Ord>          ord      = new List <Ord>();
        HttpResponseMessage response = client.GetAsync($"/ws/sparv/v2/?text={mening}" + "&settings={\"positional_attributes\":{\"lexical_attributes\":[\"pos\",\"msd\",\"lemma\"],\"dependency_attributes\":[\"ref\",\"dephead\",\"deprel\"]}}").Result;

        if (response.IsSuccessStatusCode)
        {
            var xml = new XmlDocument();
            xml.LoadXml(response.Content.ReadAsStringAsync().Result);
            var data      = (JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeXmlNode(xml));
            var sentences = data["result"]["corpus"]["text"]["paragraph"]["sentence"];
            if (sentences.Count() > 2)
            {
                foreach (var sentence in sentences)
                {
                    foreach (var word in sentence["w"])
                    {
                        Ord nyord = new Ord();
                        nyord.Term = word["#text"].Value <string>();
                        SetDef(nyord, word["@msd"].Value <string>());
                        nyord.Grundform = word["@lemma"].Value <string>();
                        ord.Add(nyord);
                    }
                }
            }
            else
            {
                if (sentences["w"].Type.ToString() == "Array")
                {
                    foreach (var word in sentences["w"])
                    {
                        Ord nyord = new Ord();
                        nyord.Term = word["#text"].Value <string>();
                        SetDef(nyord, word["@msd"].Value <string>());
                        nyord.Grundform = word["@lemma"].Value <string>();
                        ord.Add(nyord);
                    }
                }
                else
                {
                    Ord nyord = new Ord();
                    var word  = sentences["w"];
                    nyord.Term = word["#text"].Value <string>();
                    SetDef(nyord, word["@msd"].Value <string>());
                    nyord.Grundform = word["@lemma"].Value <string>();
                    ord.Add(nyord);
                }
            }
        }
        return(ord);
    }
Beispiel #17
0
        // GET: Ords/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ord ord = db.Ord.Find(id);

            if (ord == null)
            {
                return(HttpNotFound());
            }
            return(View(ord));
        }
Beispiel #18
0
        public ActionResult Create([Bind(Include = "Id,ClientId,WaiterId,TimeOpen,TimeEnd,TableId,TotalCost")] Ord ord)
        {
            if (ModelState.IsValid)
            {
                ord.TimeOpen = DateTime.Now;
                db.Ord.Add(ord);
                db.SaveChanges();
                return(RedirectToAction("Details", "Ords", new { id = ord.Id }));
            }

            ViewBag.ClientId = new SelectList(db.RegUser, "Id", "Login", ord.ClientId);
            ViewBag.TableId  = new SelectList(db.Tabl, "Id", "Number", ord.TableId);
            ViewBag.WaiterId = new SelectList(db.RegUser, "Id", "Login", ord.WaiterId);
            return(View(ord));
        }
Beispiel #19
0
        public ActionResult Edit([Bind(Include = "Id,OrdId,DishId,Status")] Meals meals)
        {
            if (ModelState.IsValid)
            {
                db.Entry(meals).State = EntityState.Modified;
                Ord curOrd = db.Ord.Find(meals.OrdId);
                db.Entry(curOrd).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Details", "Ords", new { id = meals.OrdId });
            }

            ViewBag.DishId = new SelectList(db.Dish, "Id", "Name", meals.DishId);
            ViewBag.OrdId = new SelectList(db.Ord, "Id", "Id", meals.OrdId);
            return View(meals);
        }
Beispiel #20
0
        // GET: Ords/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ord ord = db.Ord.Find(id);
            IEnumerable <Meals> MenuMeals = db.Meals.Where(u => u.OrdId == id).AsEnumerable();

            ViewBag.dishes = MenuMeals;
            if (ord == null)
            {
                return(HttpNotFound());
            }
            return(View(ord));
        }
Beispiel #21
0
        // GET: Ords/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ord ord = db.Ord.Find(id);

            if (ord == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClientId = new SelectList(db.RegUser, "Id", "Login", ord.ClientId);
            ViewBag.TableId  = new SelectList(db.Tabl, "Id", "Number", ord.TableId);
            ViewBag.WaiterId = new SelectList(db.RegUser, "Id", "Login", ord.WaiterId);
            return(View(ord));
        }
    public Ord DefineraOrd(string ord)
    {
        Ord nyord = new Ord();
        HttpResponseMessage response = client.GetAsync($"/ws/sparv/v2/?text={ord}" + "&settings={\"positional_attributes\":{\"lexical_attributes\":[\"pos\",\"msd\",\"lemma\"]}}").Result;

        if (response.IsSuccessStatusCode)
        {
            var xml = new XmlDocument();
            xml.LoadXml(response.Content.ReadAsStringAsync().Result);
            var data = (JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeXmlNode(xml));
            var word = data["result"]["corpus"]["text"]["paragraph"]["sentence"]["w"];
            SetDef(nyord, word["@msd"].Value <string>());
            nyord.Term      = ord;
            nyord.Grundform = word["@lemma"].Value <string>();
        }
        return(nyord);
    }
Beispiel #23
0
        /// <summary>
        /// Generate infinite range of es by step
        /// </summary>
        /// <param name="from">Staring element</param>
        /// <param name="by">Step</param>
        public static IEnumerable <int> EnumFromBy(int from, int by)
        {
            var current = from;

            var direction = AInt32.Class.Compare(by, 0);

            while (true)
            {
                yield return(current);

                current += by;

                if (Ord.Compare(AInt32.Class.Compare(current, from), direction).IsNeq())
                {
                    yield break;
                }
            }
        }
Beispiel #24
0
        public ActionResult DeleteConfirmed(int id)
        {
            Meals meals = db.Meals.Find(id);
            Ord curOrd = db.Ord.Find(meals.OrdId);

            if (curOrd != null && curOrd.TimeEnd != null)
            {
                ViewBag.IsOrdClosed = false;
                curOrd.TotalCost -= db.Dish.Find(meals.DishId).Price;
                db.Meals.Remove(meals);
                db.Entry(curOrd).State = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                ViewBag.IsOrdClosed = true;
            }
            return RedirectToAction("Details", "Ords", new { id = meals.OrdId });
        }
Beispiel #25
0
        public void Reset()
        {
            // clear = false;
            deleteCount = 0;
            insertCount = 0;

            if (deleteList.Length > 3 * 1024)
            {
                deleteIdxs = emptyArray;
                deleteList = emptyArray;
            }

            if (insertList.Length > 3 * 1024)
            {
                insertList = emptyArray;
            }

            currOrd = Ord.ORD_NONE;
        }
 private void SetDef(Ord ord, string input)
 {
     foreach (var ms in input.Split('.', '+'))
     {
         if (Ordklass.ContainsKey(ms))
         {
             ord.Ordklass = Ordklass[ms];
         }
         else if (Genus.ContainsKey(ms))
         {
             ord.Genus = Genus[ms];
         }
         else if (Numerus.ContainsKey(ms))
         {
             ord.Numerus = Numerus[ms];
         }
         else if (Bestämdhet.ContainsKey(ms))
         {
             ord.Bestämdhet = Bestämdhet[ms];
         }
         else if (Substantivform.ContainsKey(ms))
         {
             ord.SubstantivForm = Substantivform[ms];
         }
         else if (Komparation.ContainsKey(ms))
         {
             ord.Komparation = Komparation[ms];
         }
         else if (Satsdel.ContainsKey(ms))
         {
             ord.Satsdel = Satsdel[ms];
         }
         else if (Verbform.ContainsKey(ms))
         {
             ord.Verbform = Verbform[ms];
         }
         else if (Övrigt.ContainsKey(ms))
         {
             ord.Övrigt = Övrigt[ms];
         }
     }
 }
Beispiel #27
0
        // GET: Meals/Create
        public ActionResult Create(int? ordId)
        {
            if (ordId == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            IEnumerable<Meals> MenuMeals = db.Meals.Where(u => u.OrdId == ordId).AsEnumerable();
            Meals CurrentMeal = new Meals();
            CurrentMeal.OrdId = ordId ?? CurrentMeal.OrdId;
            Ord CurrentOrder = db.Ord.Find(ordId);
            ViewBag.DishId = new SelectList(db.Dish, "Id", "Name");
            ViewBag.dishes = MenuMeals;
            ViewBag.IsOrdClosed = false;
            if (CurrentOrder.TimeEnd != null)
            {
                ViewBag.IsOrdClosed = true;
            }

            return View(CurrentMeal);
        }
Beispiel #28
0
        public ActionResult Edit([Bind(Include = "Id,ClientId,WaiterId,TimeOpen,TimeEnd,TableId,TotalCost")] Ord ord)
        {
            if (ModelState.IsValid)
            {
                if (ord.TimeEnd != null)
                {
                    DateTime te = ord.TimeEnd ?? DateTime.Now;
                    ord.TimeEnd = te.ToUniversalTime();
                }
                DateTime to = ord.TimeOpen;
                ord.TimeOpen = to.ToUniversalTime();

                db.Entry(ord).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ClientId = new SelectList(db.RegUser, "Id", "Login", ord.ClientId);
            ViewBag.TableId  = new SelectList(db.Tabl, "Id", "Number", ord.TableId);
            ViewBag.WaiterId = new SelectList(db.RegUser, "Id", "Login", ord.WaiterId);
            return(View(ord));
        }
Beispiel #29
0
        /// <summary>
        /// Generate range of es with step
        /// </summary>
        /// <param name="from">Starting element</param>
        /// <param name="by">Step</param>
        /// <param name="to">The last element in a sequence (or the point of non-crossing)</param>
        public static IEnumerable <int> EnumFromByTo(int from, int by, int to)
        {
            var alg = AInt32.Class;

            var direction = alg.Compare(to, from);

            // if no step needed to be made then yield only one element
            if (direction.IsEq())
            {
                yield return(from);

                yield break;
            }

            var next = alg.Add(from, by);

            // calculate direction to move
            var stepDirection = alg.Compare(next, from);

            // if step doesn't get us closer to `to` then nothing to enumerate
            if (Ord.Compare(direction, stepDirection).IsNeq())
            {
                yield break;
            }

            var current = from;

            while (true)
            {
                if (Ord.Compare(alg.Compare(to, current), direction).IsNeq() && alg.Equal(current, to).Not())
                {
                    yield break;
                }

                yield return(current);

                current = alg.Add(current, by);
            }
        }
Beispiel #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                Ord o = new Ord();
                o = Ord.Fetch(Convert.ToInt32(Request.QueryString["id"].ToString()));

                txtUserID.Text = o.UserID.ToString();
                txtStatusID.Text = o.StatusID.ToString();
                txtOrderDate.Text = o.OrderDate.ToString();
                txtOrderAddress1.Text = o.OrderAdd1;
                txtOrderAddress2.Text = o.OrderAdd2;
                txtOrderCity.Text = o.OrderCity;
                txtStateID.Text = o.StatusID.ToString();
                txtOrderZip.Text = o.OrderZip;
                txtOrderLastUpdate.Text = o.OrderLastUpdate.ToString();

                }
        }

        lblError.Visible = false;
    }
Beispiel #31
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                Ord o = new Ord();
                o = Ord.Fetch(Convert.ToInt32(Request.QueryString["id"].ToString()));


                txtUserID.Text          = o.UserID.ToString();
                txtStatusID.Text        = o.StatusID.ToString();
                txtOrderDate.Text       = o.OrderDate.ToString();
                txtOrderAddress1.Text   = o.OrderAdd1;
                txtOrderAddress2.Text   = o.OrderAdd2;
                txtOrderCity.Text       = o.OrderCity;
                txtStateID.Text         = o.StatusID.ToString();
                txtOrderZip.Text        = o.OrderZip;
                txtOrderLastUpdate.Text = o.OrderLastUpdate.ToString();
            }
        }

        lblError.Visible = false;
    }
Beispiel #32
0
    public static Ord Fetch(int id)
    {
        Ord o = new Ord();
        //connection object - ConfigurationManager namespace allows for runtime
        //access to web.config setting, specifically connection strings and key values
        SqlConnection cn = new
            SqlConnection(ConfigurationManager.ConnectionStrings["cs"].ConnectionString);
        //command object is for direct interface with database
        //this constructor uses 2 arguments, first is name of stored procedure,
        //2nd is connection object
        SqlCommand cmd = new SqlCommand("spGetOrderByID", cn);
        //Create datatable to hold result set
        DataTable dt = new DataTable();
        // Mark the Command as a Stored Procedure
        //command type is an enumeration: Stored procedure, text(embedded SQL) or table direct
        cmd.CommandType = CommandType.StoredProcedure;

        // Add Parameters to Stored Procedure
        cmd.Parameters.Add("@OrderID", SqlDbType.Int).Value = id;

        // Open the database connection and execute the command
        try
        {
            //opens connection to database, most failures happen here
            //check connection string for proper settings
            cn.Open();
            //data adapter object is trasport link between data source and
            //data destination
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            //fill method, for multiple tables use dataset
            da.Fill(dt);
        }
        catch (Exception exc)
        {
            //just put here to make debugging easier, can look at error directly
            exc.ToString();
        }
        finally
        {
            //must always close connections
            cn.Close();
        }

        // Return the dataset
        if (dt.Rows.Count > 0)
        {
            o.OrderID = Convert.ToInt32(dt.Rows[0]["OrderID"].ToString());
            o.UserID = Convert.ToInt32(dt.Rows[0]["UserID"].ToString());
            o.StatusID = Convert.ToInt32(dt.Rows[0]["StatusID"].ToString());
            o.OrderDate = Convert.ToDateTime(dt.Rows[0]["OrderDate"].ToString());
            o.OrderAdd1 = dt.Rows[0]["OrderAdd1"].ToString();
            o.OrderAdd2 = dt.Rows[0]["OrderAdd2"].ToString();
            o.OrderCity = dt.Rows[0]["OrderCity"].ToString();
            o.StateID = Convert.ToInt32(dt.Rows[0]["StateID"].ToString());
            o.OrderZip = dt.Rows[0]["OrderZip"].ToString();
            o.OrderLastUpdate = Convert.ToDateTime(dt.Rows[0]["OrderLastUpdate"].ToString());

        }
        return o;
    }
Beispiel #33
0
    public static bool Save(Ord o)
    {
        bool b = false;

        //connection object - ConfigurationManager namespace allows for runtime
        //access to web.config setting, specifically connection strings and key values
        SqlConnection cn = new
            SqlConnection(ConfigurationManager.ConnectionStrings["cs"].ConnectionString);
        //command object is for direct interface with database
        //this constructor uses 2 arguments, first is name of stored procedure,
        //2nd is connection object
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = cn;
        if (o.OrderID > 0)
        {
            cmd.CommandText = "spUpdateOrder";
            cmd.Parameters.Add("@OrderID", SqlDbType.Int).Value = o.OrderID;
        }
        else
        {
            cmd.CommandText = "spInsertOrder";
        }

        //Create datatable to hold result set
        DataTable dt = new DataTable();
        // Mark the Command as a Stored Procedure
        //command type is an enumeration: Stored procedure, text(embedded SQL) or table direct
        cmd.CommandType = CommandType.StoredProcedure;

        // Add Parameters to Stored Procedure
        cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = o.UserID;
        cmd.Parameters.Add("@StatusID", SqlDbType.Int).Value = o.StatusID;
        cmd.Parameters.Add("@OrderDate", SqlDbType.Date).Value = o.OrderDate;
        cmd.Parameters.Add("@OrderAdd1", SqlDbType.VarChar).Value = o.OrderAdd1;
        cmd.Parameters.Add("@OrderAdd2", SqlDbType.VarChar).Value = o.OrderAdd2;
        cmd.Parameters.Add("@OrderCity", SqlDbType.VarChar).Value = o.OrderCity;
        cmd.Parameters.Add("@StateID", SqlDbType.Int).Value = o.StateID;
        cmd.Parameters.Add("@OrderZip", SqlDbType.VarChar).Value = o.OrderZip;
        cmd.Parameters.Add("@OrderLastUpdate", SqlDbType.Date).Value = o.OrderLastUpdate;

        // Open the database connection and execute the command
        try
        {
            //opens connection to database, most failures happen here
            //check connection string for proper settings
            cn.Open();
            //execute
            cmd.ExecuteNonQuery();
            b = true;
        }
        catch (Exception exc)
        {
            //just put here to make debugging easier, can look at error directly
            exc.ToString();
            b = false;
        }
        finally
        {
            //must always close connections
            cn.Close();
        }

        // Return the dataset
        return b;
    }
Beispiel #34
0
        public computeImports(string path, DataTable table)
        {
            uint hLib = LoadLibraryEx(path, 0, 0);
            uint size = 0;
            IMAGE_IMPORT_DESCRIPTOR *pIID = (IMAGE_IMPORT_DESCRIPTOR *)ImageDirectoryEntryToData((void *)hLib, true, 1, out size);

            if (hLib != 0 && pIID != null)
            {
                table.Columns.Add("import function", typeof(string));
                table.Columns.Add("address", typeof(string));
                table.Columns.Add("dll", typeof(string));
                table.Columns.Add("ordinal", typeof(string));
                while (pIID->OriginalFirstThunk != 0)
                {
                    char *      szName    = (char *)(hLib + pIID->Name);
                    string      name      = Marshal.PtrToStringAnsi((IntPtr)szName);
                    THUNK_DATA *pThunkOrg = (THUNK_DATA *)(hLib + pIID->OriginalFirstThunk);
                    while (pThunkOrg->AddressOfData != 0)
                    {
                        char *szImportName;
                        uint  Ord;
                        if ((pThunkOrg->Ordinal & 0x80000000) > 0)
                        {
                            Ord = pThunkOrg->Ordinal & 0xffff;
                            table.Rows.Add("", pThunkOrg->Function.ToString("X8"), name, Ord.ToString());
                        }
                        else
                        {
                            IMAGE_IMPORT_BY_NAME *pIBN = (IMAGE_IMPORT_BY_NAME *)(hLib + pThunkOrg->AddressOfData);
                            if (!IsBadReadPtr((void *)pIBN, (uint)sizeof(IMAGE_IMPORT_BY_NAME)))
                            {
                                Ord          = pIBN->Hint;
                                szImportName = (char *)pIBN->Name;
                                string sImportName = Marshal.PtrToStringAnsi((IntPtr)szImportName);
                                table.Rows.Add(sImportName, pThunkOrg->Function.ToString("X8"), name, Ord.ToString());
                            }
                            else
                            {
                                break;
                            }
                        }
                        pThunkOrg++;
                    }
                    pIID++;
                }
                table.DefaultView.Sort = "import function";
            }
        }