public void SetView(HeroData heroData, Officer o)
    {
        officerID = o.ID;
        hd        = heroData;
        text      = o.Post;


        take_cr.SetAlpha(TestColor(false) == heroData.HeroId ? 1 : 0);
        down_obj.SetActive(false);
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < o.attrerty.Length; i++)
        {
            Pro p = o.attrerty[i];
            sb.Append(AttrUtil.GetAttribute(p.attr));
            sb.Append(string.Format("<color=#00FF00> +{0}</color>", p.num));
            if ((i + 1) % 2 != 0)
            {
                sb.Append("              ");
            }
            else
            {
                sb.Append("\n");
            }
        }
        leftpro_txt.text = sb.ToString();
    }
Exemple #2
0
        public void HarRaad(string bogPengeString)
        {
            Pro fejl1 = new Pro();

            Pris = 150;
            int bogPenge = 0;

            try
            {
                bogPenge = Convert.ToInt32(bogPengeString);
                Console.WriteLine();
            }
            catch (Exception)
            {
                fejl1.Fejl();
            }


            if (bogPenge >= Pris)
            {
                Console.WriteLine("Jeg har raad.");
            }
            else
            {
                Console.WriteLine("Jeg har desvaere ikke raad.");
            }
        }
Exemple #3
0
    public EquipData(EquipMsg msg)
    {
        md5          = msg.md5;
        EquipId      = msg.equipID;
        Exp          = msg.exp;;
        HeroId       = msg.heroID;
        StrengthenLv = msg.strengthenLv;
        int length = msg.randomWish.Length;

        wishs = new RandomWish[length];
        for (int i = 0; i < length; ++i)
        {
            wishs[i].wish = new Pro
            {
                attr = msg.randomWish[i].attr,
                num  = msg.randomWish[i].num,
                per  = msg.randomWish[i].per
            };
            wishs[i].isLock = msg.randomWish[i].isLock;
        }
        length    = msg.tempWish.Length;
        tempWishs = new Pro[length];
        for (int i = 0; i < length; ++i)
        {
            tempWishs[i] = new Pro
            {
                attr = msg.tempWish[i].attr,
                num  = msg.tempWish[i].num,
                per  = msg.tempWish[i].per
            };
        }
    }
Exemple #4
0
 void PopulateArray()
 {
     foreach (GameObject Pro in projectiles)
     {
         Pro.SetActive(false);
     }
 }
Exemple #5
0
    public static void Main()
    {
        Pro p = new Pro();

        Console.WriteLine(p.i);
        //Console.WriteLine(p.j);  //'P.j' is inaccessible due to its protection level
    }
        /// <summary>
        /// Inserts values of all ExcelTableEntity properties to DataTable
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="dtEntityInfo"></param>
        private void InsertEntityDataToTable(object obj, System.Data.DataTable dtEntityInfo)
        {
            DataRow row = dtEntityInfo.Rows.Add();

            //Lists all Properties of ExcelTableEntity
            Type entityType = typeof(ExcelTableEntity);

            PropertyInfo[] ProList = entityType.GetProperties();
            foreach (PropertyInfo Pro in ProList)
            {
                if (Pro.PropertyType.Name.Contains("IDictionary"))
                {
                    Dictionary <string, EntityProperty> dicEntity = (Dictionary <string, EntityProperty>)Pro.GetValue(obj, null);

                    foreach (string key in dicEntity.Keys)
                    {
                        if (!dtEntityInfo.Columns.Contains(key))
                        {
                            DataColumn col = new DataColumn(key);
                            dtEntityInfo.Columns.Add(col);
                        }
                        row[key] = dicEntity[key].PropertyAsObject.ToString();
                    }
                }
                else if (Pro.Name != "ETag")
                {
                    row[Pro.Name] = Pro.GetValue(obj, null).ToString();
                }
            }
        }
Exemple #7
0
    static void Main()
    {
        Pro <int>    obj  = new Pro <int>(55);
        Pro <string> obj1 = new Pro <string>("ashok");

        Console.ReadLine();
    }
Exemple #8
0
        private static void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            SyncData.SetSunc(false);
            new ClassPrintCheck(RepositoryCheck.DocumentProductCheck, false);
            RepositoryCheck.DocumentProductCheck = null;
            CassieService.OpenProductsCheck();
            Pro     = null;
            Ndevis  = -1;
            Nfact   = -1;
            Check   = null;
            Devis   = false;
            ModePro = false;

            RepositoryDiscount.RestoreDiscount();
            CheckService.DiscountCalc();
            FunctionsService.WriteTotal();

            var de = ClassEtcFun.FindWindow("_W_Message");

            if (de != null)
            {
                de.Close();
            }

            var mw = ClassEtcFun.FindWindow("MainWindow_");

            if (mw != null)
            {
                mw.IsEnabled = true;
            }
        }
Exemple #9
0
        //Methods
        /// <summary>
        /// Construct the truth table
        /// </summary>
        public void GenerateTruthTable()
        {
            //number of rows = 2^number of variables
            int nrOfRows = Convert.ToInt32(Math.Pow(2, varName.Count));

            for (int i = 0; i < nrOfRows; i++)
            {
                int varIndexInRow = 0;

                //Create a list of variables for each row
                List <Pro> varList = new List <Pro>();

                for (int j = varName.Count - 1; j >= 0; j--)
                {
                    Pro myVar = new Pro();
                    myVar.Notation = varName[varIndexInRow]; //set notation
                    int value = i / Convert.ToInt32(Math.Pow(2, j)) % 2;
                    myVar.BooleanValue = value == 1;         //set boolean value

                    varList.Add(myVar);
                    varIndexInRow++;
                }

                rows.Add(new Row(varList));
            }
        }
 public void Start()
 {
     foreach (Process Pro in ProcessList)
     {
         Pro.Start(); Pro.WaitForExit();
     }
 }
Exemple #11
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txtName.Text))
        {
            Pro p = new Pro();
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                p.ProductID = Convert.ToInt32(Request.QueryString["id"].ToString());
            }
            else
            {
                p.ProductID = 0;
            }
            p.ProductName     = txtName.Text;
            p.ProductDesc     = txtDescription.Text;
            p.ProductSKU      = txtSKU.Text;
            p.TeamID          = ddlTeam.SelectedIndex;
            p.ProductCost     = Convert.ToDecimal(txtPrice.Text);
            p.ProductIsActive = Convert.ToBoolean(rblIsActive.SelectedValue.ToString());

            if (Pro.Save(p))
            {
                Response.Redirect("~/Products.aspx");
            }
            else
            {
                lblError.Text = "Error saving record.";
            }
        }
    }
Exemple #12
0
        public void TestMethod1()
        {
            var R = new Raw {
                Name = "raw"
            };
            var RT = new Raw {
                Name = "raw2"
            };

            var P = new Pro {
                Name = "praw"
            };
            var PT = new Pro {
                Name = "praw2"
            };
            var B = new Blend {
                Name = "Blend"
            };
            var BT = new Blend {
                Name = "Blend2"
            };

            using (var dt = new AshleyGraham()) {
                dt.Database.EnsureCreated();
                dt.Pros.AddRange(P, PT);
                dt.Raws.AddRange(R, RT);
                dt.Blends.AddRange(B, BT);
                dt.SaveChanges();
            }

            using (var dt = new AshleyGraham()) {
                var a = dt.Model.ToString();
            }
        }
Exemple #13
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string Part;
            string Pro;
            int    Qty = Convert.ToInt32(textBox1.Text);

            Part = CboPart.SelectedItem.ToString();

            int PartID = Convert.ToInt32((Part.Substring(0, 2)).Trim());

            Pro = cboProduct.SelectedItem.ToString();
            int ProID = Convert.ToInt32((Pro.Substring(0, 2)).Trim());

            string    findKR   = "select max(id) as MAXID from kit_relations;";
            DBConnect findID   = new DBConnect();
            string    maxID    = findID.FindMaxID(findKR);
            int       newMaxID = Convert.ToInt32(maxID) + 1;


            string    Updatekit    = "Update kit_relations SET part_qty = " + Qty + " WHERE part_id = " + PartID + " and product_id = " + ProID + ";";
            DBConnect insertkitqry = new DBConnect();

            insertkitqry.Updatedata(Updatekit);
            MessageBox.Show("Quantity of Part has been added.");
        }
Exemple #14
0
        public int GetCommentLeft(Pro iPro)
        {
            var v = GetAll().ToList().Where(m =>
                                            m.ShpId == iPro.ShpId && m.ProId == iPro.ProId && !string.IsNullOrEmpty(m.Cmt));

            return(v.Count());
        }
Exemple #15
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txtName.Text))
        {
            Pro p = new Pro();
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                p.ProductID = Convert.ToInt32(Request.QueryString["id"].ToString());
            }
            else
            {
                p.ProductID = 0;
            }
            p.ProductName = txtName.Text;
            p.ProductDesc = txtDescription.Text;
            p.ProductSKU = txtSKU.Text;
            p.TeamID = ddlTeam.SelectedIndex;
            p.ProductCost = Convert.ToDecimal(txtPrice.Text);
            p.ProductIsActive = Convert.ToBoolean(rblIsActive.SelectedValue.ToString());

            if (Pro.Save(p))
            {
                Response.Redirect("~/Products.aspx");
            }
            else
            {
                lblError.Text = "Error saving record.";
            }

        }
    }
Exemple #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String Keyword  = Request.QueryString["Keyword"];
            int    Category = Convert.ToInt32(Request.QueryString["Category"]);

            Classes.ProductsList pl      = new Classes.ProductsList();
            ArrayList            ProList = pl.ReturnSearchedProducts(Keyword, Category);

            Literal1.Text = "";
            String a = "";

            foreach (Classes.Product Pro in ProList)
            {
                a += "<div style=\"height: 130px; width: 552px; background-image: url('Themes/images/Product_List_Bg.png'); background-repeat: no-repeat; margin-bottom: 12px;\">";
                a += "<table style=\"width: 100%; height: 128px\"><tr><td style=\"width: 140px\"><div style=\"padding: 17px 6px 17px 17px; width: 117px; height: 96px\"><a href=\"product.aspx?id=" + Pro.getID() + "\">";
                a += "<img src=\"images/product/" + Pro.getID() + ".jpg" + "  \" style=\"margin: auto\" height=\"90\" align=\"middle\" width=\"112\" /></a></div></td><td style=\"width: 297px\" valign=\"top\">";
                a += "<div style=\"padding: 10px 20px 10px 10px; font-size: 14px; color: #015ba7; font-weight: 400;\"><a href=\"product.aspx?id=" + Pro.getID() + "\">" + Pro.getName() + "</a></div>";
                a += "<div style=\"padding: 2px 20px 16px 10px; height: 71px; width: 267px;\"><div style=\"margin-top: auto; margin-bottom: auto\">" + Pro.getDetails() + "</div>";
                a += "</div></td><td style=\"width: 101px\" valign=\"top\"><div style=\"height: 28px; padding-top: 11px; color: #015ba7; font-size: 14px;\" align=\"center\">";
                a += "" + Pro.getPrice() + " USD" + "</div><div style=\"height: 63px; padding-top: 18px;\" align=\"center\">" + Pro.getEndDate() + "</div></td></tr></table></div>";



                Literal1.Text = a;
            }
        }
Exemple #17
0
        private void LoadPoopy()
        {
            var R = new Raw {
                Name = "raw"
            };
            var RT = new Raw {
                Name = "raw2"
            };

            var P = new Pro {
                Name = "praw"
            };
            var PT = new Pro {
                Name = "praw2"
            };
            var B = new Blend {
                Name = "Blend"
            };
            var BT = new Blend {
                Name = "Blend2"
            };

            using (var dt = new AshleyGraham()) {
                dt.Database.EnsureCreated();
                dt.Pros.AddRange(P, PT);
                dt.Raws.AddRange(R, RT);
                dt.Blends.AddRange(B, BT);
                dt.SaveChanges();
            }
        }
Exemple #18
0
 public void MinionNext()
 {
     using (var dt = new AshleyGraham()) {
         var index = dt.Pros.ToList().FindIndex(i => i.Id == Pro.Id);
         var Count = dt.Pros.Count();
         Pro = dt?.Pros?.ToList().ElementAt((index + 1) % Count);
     }
 }
Exemple #19
0
        public ActionResult DeleteConfirmed(int id)
        {
            Pro pro = db.Pros.Find(id);

            db.Pros.Remove(pro);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #20
0
        /// 根据类型创建sql
        private string BaseSql(OpType o)
        {
            ProList = Type_Table.GetProperties();
            string           sql   = "";
            DataMapAttribute table = Type_Table.GetCustomAttributes(typeof(DataMapAttribute), true)[0] as DataMapAttribute;

            switch (o)
            {
            case OpType.SELECT:
                sql = "SELECT ";
                //枚举每一个属性比较
                foreach (PropertyInfo Pro in ProList)
                {
                    object[] objAttrs = Pro.GetCustomAttributes(typeof(DataMapAttribute), true);
                    if (objAttrs.Length > 0)
                    {
                        DataMapAttribute attr = objAttrs[0] as DataMapAttribute;
                        if (attr.Column != null)
                        {
                            sql += attr.Column + ",";
                        }
                    }
                }
                sql  = sql.Substring(0, sql.Length - 1);
                sql += " FROM " + table.TableName + " WHERE 1=1";     //Type_Table.Name;
                break;

            case OpType.INSERT:
                sql = "INSERT INTO " + table.TableName + "(";
                foreach (PropertyInfo Pro in ProList)
                {
                    object[] objAttrs = Pro.GetCustomAttributes(typeof(DataMapAttribute), true);
                    if (objAttrs.Length > 0)
                    {
                        DataMapAttribute attr = objAttrs[0] as DataMapAttribute;
                        if (attr.Column != null)
                        {
                            if (attr.Column != "ID")        //id自增
                            {
                                sql += attr.Column + ",";
                            }
                        }
                    }
                }
                sql  = sql.Substring(0, sql.Length - 1);
                sql += ")VALUES(";
                break;

            case OpType.UPDATE:
                sql = "UPDATE " + table.TableName + " SET ";
                break;

            case OpType.DELETE:
                sql = "DELETE FROM " + table.TableName + " WHERE 1=1 ";
                break;
            }
            return(sql);
        }
Exemple #21
0
 public TestMinion()
 {
     //   LoadPoopy();
     using (var dt = new AshleyGraham()) {
         dt.Database.EnsureCreated();
         Pro   = dt.Pros?.FirstOrDefault();
         Blend = Pro?.Blend;
     }
 }
Exemple #22
0
 public ActionResult Edit(Pro pro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pro).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(pro);
 }
Exemple #23
0
 public ActionResult Edit([Bind(Include = "ProID,Name")] Pro pro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pro));
 }
Exemple #24
0
        public IActionResult GetListBoughtProducts()
        {
            AccountOrder accountOrder = new AccountOrder();
            var          apiRep       = new APIResponse();
            var          userId       = string.Empty;

            if (HttpContext.User.Identity is ClaimsIdentity identity)
            {
                userId = identity.FindFirst(ClaimTypes.Name).Value;
            }
            accountOrder.AccountId = userId;
            List <Order> Orders = _orderService.Get();

            if (Orders == null)
            {
                apiRep.Error   = true;
                apiRep.Message = "Can't not find list order";
                return(BadRequest(apiRep));
            }
            foreach (Order item in Orders)
            {
                if (item.AccountId == accountOrder.AccountId)
                {
                    for (var i = 0; i < item.orderinfo.carts.Length; i++)
                    {
                        var flag  = 0;
                        var index = 0;
                        for (var j = 0; j < accountOrder.carts.Count; j++)
                        {
                            for (var k = 0; k < accountOrder.carts.Count; k++)
                            {
                                if (accountOrder.carts[j].ProductId.ToString() == item.orderinfo.carts[i].ProductId)
                                {
                                    flag  = 1;
                                    index = j;
                                    break;
                                }
                            }
                        }
                        if (flag == 0)
                        {
                            Pro pro = new Pro();
                            pro = item.orderinfo.carts[i];
                            accountOrder.carts.Add(pro);
                        }
                        else
                        {
                            accountOrder.carts[index].Amount += item.orderinfo.carts[i].Amount;
                        }
                    }
                    apiRep.Data = accountOrder;
                }
            }
            return(Ok(apiRep));
        }
Exemple #25
0
        public ActionResult Create([Bind(Include = "ProID,Name")] Pro pro)
        {
            if (ModelState.IsValid)
            {
                db.Pros.Add(pro);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pro));
        }
Exemple #26
0
        public ActionResult Create(Pro pro)
        {
            if (ModelState.IsValid)
            {
                db.Pros.Add(pro);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pro));
        }
    protected void btnGem_Click2(object sender, EventArgs e)
    {
        Pro objPort = new Pro();

        objPort.Tekst = litTekst2.Text;
        objPort.ID = int.Parse(txtID2.Text);
        objPort.Tekst = litTekst2.Text.Replace(Environment.NewLine, "<br />");
        Fac objVinoFac = new Fac();
        objVinoFac.redigerForside2(objPort);
        Response.Redirect("Default.aspx");
    }
Exemple #28
0
        private static void SaveFile()
        {
            var root = new XElement("Pros");

            foreach (var pro in Pros)
            {
                root.Add(Pro.ToXElement(pro));
            }

            File.WriteAllText(Path, new XDocument(root).ToString());
        }
Exemple #29
0
        public ActionResult Create(Pro pro)
        {
            if (ModelState.IsValid)
            {
                db.Pros.Add(pro);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }

            return View(pro);
        }
    protected void btnGem_Click2(object sender, EventArgs e)
    {
        Pro objPort = new Pro();

        objPort.Tekst = litTekst2.Text;
        objPort.ID    = int.Parse(txtID2.Text);
        objPort.Tekst = litTekst2.Text.Replace(Environment.NewLine, "<br />");
        Fac objVinoFac = new Fac();

        objVinoFac.redigerForside2(objPort);
        Response.Redirect("Default.aspx");
    }
Exemple #31
0
        private static void LoadFile()
        {
            if (File.Exists(Path))
            {
                var document = XDocument.Load(Path);

                Pros.Clear();
                foreach (var element in document.GetXElements("Pros", "rec"))
                {
                    Pros.Add(Pro.FromXElement(element));
                }
            }
        }
Exemple #32
0
        /// <summary>
        ///Return the new row that is the copy
        /// </summary>
        public Row CopyRow()
        {
            List <Pro> newVarList = new List <Pro>();

            for (int i = 0; i < vars.Count; i++)
            {
                Pro v = new Pro();
                v.Notation     = GetVariables()[i].Notation;
                v.BooleanValue = GetVariables()[i].BooleanValue;
                newVarList.Add(v);
            }
            return(new Row(newVarList));
        }
        public ActionResult Create(Pro pro)
        {
            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #34
0
        public IActionResult GetAccountOrder(String userId)
        {
            AccountOrder accountOrder = new AccountOrder();
            var          apiRep       = new APIResponse();

            accountOrder.AccountId = userId;
            List <Order> Orders = _orderService.Get();

            if (Orders == null)
            {
                apiRep.Error   = true;
                apiRep.Message = "Can't not find list order";
                return(BadRequest(apiRep));
            }
            foreach (Order item in Orders)
            {
                if (item.AccountId == accountOrder.AccountId)
                {
                    for (var i = 0; i < item.orderinfo.carts.Length; i++)
                    {
                        var flag  = 0;
                        var index = 0;
                        for (var j = 0; j < accountOrder.carts.Count; j++)
                        {
                            for (var k = 0; k < accountOrder.carts.Count; k++)
                            {
                                if (accountOrder.carts[j].ProductId.ToString() == item.orderinfo.carts[i].ProductId)
                                {
                                    flag  = 1;
                                    index = j;
                                    break;
                                }
                            }
                        }
                        if (flag == 0)
                        {
                            Pro pro = new Pro();
                            pro = item.orderinfo.carts[i];
                            accountOrder.carts.Add(pro);
                        }
                        else
                        {
                            accountOrder.carts[index].Amount += item.orderinfo.carts[i].Amount;
                        }
                    }
                    apiRep.Data = accountOrder;
                }
            }
            return(Ok(apiRep));
        }
Exemple #35
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!string.IsNullOrEmpty(Request.QueryString["id"]))
         {
             Pro p = new Pro();
             p = Pro.Fetch(Convert.ToInt32(Request.QueryString["id"].ToString()));
             txtName.Text = p.ProductName;
             txtDescription.Text = p.ProductDesc;
             txtSKU.Text = p.ProductSKU;
             ddlTeam.SelectedIndex = p.TeamID;
             txtPrice.Text = p.ProductCost.ToString();
             rblIsActive.SelectedValue = p.ProductIsActive.ToString();
         }
     }
     lblError.Visible = false;
 }
Exemple #36
0
    public Character(int money, int health, int maxHealth, int def, int dodge, string objName, bool isOnLinePlayer, int stamina, int  maxStamina, Pro pro, int level, int exp, List<Equipment> eList, int logId)
    {
        this.money = money;
        this.Health = health;
        this.MaxHealth = maxHealth;
        this.Def = def;
        this.dodge = dodge;
        this.ObjName = objName;
        this.PrefabName = "_images/_game/" + pro.prefabname;
        this.isOnLinePlayer = isOnLinePlayer;
        this.stamina = stamina;
        this.maxStamina = maxStamina;
        this.Pro = pro;
        this.level = level;
        this.exp = exp;
        this.nextLevelExp = level * LEVELEXPADD;
        this.logId = logId;
        this.EquipList = eList;

        //玩家的属性->基本属性+装备属性
        AddExp (0);
    }
Exemple #37
0
    public static bool Save(Pro p)
    {
        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 (p.ProductID > 0)
        {
            cmd.CommandText = "spUpdateProduct";
            cmd.Parameters.Add("@ProductID", SqlDbType.Int).Value = p.ProductID;
        }
        else
        {
            cmd.CommandText = "spInsertProduct";
        }
        //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("@TeamID", SqlDbType.VarChar).Value = p.TeamID;
        cmd.Parameters.Add("@ProductName", SqlDbType.VarChar).Value = p.ProductName;
        cmd.Parameters.Add("@ProductDesc", SqlDbType.VarChar).Value = p.ProductDesc;
        cmd.Parameters.Add("@ProductSKU", SqlDbType.VarChar).Value = p.ProductSKU;
        cmd.Parameters.Add("@ProductCost", SqlDbType.Decimal).Value = p.ProductCost;
        cmd.Parameters.Add("@ProductIsActive", SqlDbType.Bit).Value = p.ProductIsActive;

        // 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;
    }
Exemple #38
0
    public static Pro Fetch(int id)
    {
        Pro p = new Pro();

            SqlConnection cn = new
                SqlConnection(ConfigurationManager.ConnectionStrings["cs"].ConnectionString);

            SqlCommand cmd = new SqlCommand("spGetProductByID", cn);

            DataTable dt = new DataTable();

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@ProductID", SqlDbType.Int).Value = id;

            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)
            {
                p.ProductID = Convert.ToInt32(dt.Rows[0]["ProductID"].ToString());
                p.TeamID = Convert.ToInt32(dt.Rows[0]["TeamID"].ToString());
                p.ProductName = dt.Rows[0]["ProductName"].ToString();
                p.ProductDesc = dt.Rows[0]["ProductDesc"].ToString();
                p.ProductSKU = dt.Rows[0]["ProductSKU"].ToString();
                p.ProductCost = Convert.ToDecimal(dt.Rows[0]["ProductCost"].ToString());
                p.ProductIsActive = Convert.ToBoolean(dt.Rows[0]["ProductIsActive"].ToString());
            }
            return p;
    }