示例#1
0
        public IEnumerable <TradeGroup> Get()
        {
            List <TradeGroup> tradeGroups = new List <TradeGroup>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader("Select * From [dbo].[tblTradeGroup]", CommandType.Text))
            {
                while (reader.Read())
                {
                    TradeGroup tradeGroup = new TradeGroup();
                    tradeGroup.Id   = int.Parse(reader["tradeGroupId"].ToString());
                    tradeGroup.Name = reader["tradeGroupName"].ToString();
                    tradeGroups.Add(tradeGroup);
                }
            }

            return(tradeGroups);
        }
示例#2
0
        public ActionResult EditTradeGroup(TradeGroup tradeGroup)
        {
            try
            {
                //////// validation
                if (!Utilities.IsRequiredStringInputsValid(tradeGroup.Name))
                {
                    return(RedirectToAction("Error", "Home", new { message = "فیلدهای ستاره دار را بدرستی وارد کنید" }));
                }

                tradeGroup.Status = "فعال";
                tradeGroup.Name   = tradeGroup.Name.ToFarsiString().Trim();
                //////////////

                if (ModelState.IsValid)
                {
                    string message = "";
                    if (blTradeGroup.Update(tradeGroup, out message))
                    {
                        return(RedirectToAction("Groups", "GroupAndColor"));
                    }
                    else
                    {
                        if (message.Contains("TradeGroups(Name Must Unique)"))
                        {
                            return(RedirectToAction("Error", "Home", new { message = "نام گروه صنف باید یکتا باشد" }));
                        }

                        return(RedirectToAction("Error", "Home", new { message = "خطا رخ داده است. مجددا تلاش کنید" }));
                    }
                }
                else
                {
                    return(RedirectToAction("Error", "Home", new { message = "خطا رخ داده است. مجددا تلاش کنید" }));
                }
            }
            catch
            {
                return(RedirectToAction("Error", "Home", new { message = "خطا رخ داده است. مجددا تلاش کنید" }));
            }
        }
示例#3
0
        public ActionResult AddTradeGroup()
        {
            var model = new TradeGroup();

            return(View(model));
        }