Esempio n. 1
0
        public bool UpdateItem(MS_Item Item)
        {
            string sql = " Update MS_Item set ItemName=@ItemName, ItemCode=@ItemCode,ItemDescription=@ItemDescription, " +
                         " OrganizationId=@OrganizationId,CategoryId=@CategoryId, " +
                         " EnteredBy=@EnteredBy, EnteredDate=@EnteredDate,LastUpdatedBy=@LastUpdatedBy, " +
                         " LastUpdatedDate=@LastUpdatedDate, IsDeleted=0, DeletedBy=0, DeletedDate=null" +
                         " where ItemId=@ItemId";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, Item);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
Esempio n. 2
0
        public int InsertItem(MS_Item Item)
        {
            try
            {
                string sql = " Insert into  MS_Item (ItemName, ItemCode,ItemDescription,CategoryId,OrganizationId, EnteredBy, EnteredDate," +
                             " LastUpdatedBy, LastUpdatedDate, IsDeleted, DeletedBy, DeletedDate) " +
                             " values " +
                             "(@ItemName, @ItemCode,@ItemDescription,@CategoryId,@OrganizationId, @EnteredBy, @EnteredDate," +
                             " 0, null, 0, 0, null) SELECT CAST(SCOPE_IDENTITY() as int)";
                using (var db = DbHelper.GetDBConnection())
                {
                    using (var trsn = new TransactionScope())
                    {
                        //db.Execute(sql);
                        var lst = db.Query <int>(sql, Item).SingleOrDefault();
                        trsn.Complete();
                        db.Close();

                        return(lst);
                    }
                }
            }
            catch
            {
                return(0);
            }
        }
Esempio n. 3
0
        public ActionResult Create(FormCollection frm, string[] hddrowpindex)
        {
            var ses   = sesrepo.GetSessionById((User as CustomPrincipal).UserId);
            int orgid = ses.OrganizationId;

            try
            {
                MS_Item item = new MS_Item();
                item.ItemName = frm["ItemName"];
                //item.ItemCode = frm["ItemCode"];
                //item.ItemDescription = frm["ItemDescription"];
                item.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]);
                item.CategoryId     = Convert.ToInt32(frm["CategoryId"]);
                item.EnteredBy      = (User as CustomPrincipal).UserId;
                item.EnteredDate    = DateTime.Now;
                int         itemid = db.InsertItem(item);
                MS_ItemUnit uitem;
                if (hddrowpindex != null && hddrowpindex.Count() > 0)
                {
                    foreach (var unititem in hddrowpindex)
                    {
                        uitem                  = new MS_ItemUnit();
                        uitem.UnitId           = Convert.ToInt32(frm["UnitId-" + unititem]);
                        uitem.UnitSellingPrice = Convert.ToDecimal(frm["SellingPrice-" + unititem]);
                        uitem.QuantityInPiece  = Convert.ToInt32(frm["QuantityPer-" + unititem]);
                        if (frm["IsDefault-" + unititem] != null)
                        {
                            uitem.IsDefault = true;
                        }
                        else
                        {
                            uitem.IsDefault = false;
                        }
                        uitem.OrganizationId = item.OrganizationId;
                        uitem.ItemId         = itemid;
                        iu.InsertItemUnit(uitem);
                    }
                }
            }catch (Exception ex)
            {
                return(View());
            }
            ViewBag.UnitList       = udb.GetUnitList(orgid, "", "");
            ViewBag.CategoryId     = new SelectList(ddl.GetCategoryList(orgid), "Id", "Name");
            ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name");
            return(RedirectToAction("Index"));
        }