コード例 #1
0
        public bool InsertItemUnit(MS_ItemUnit itemunit)
        {
            string sql = " Insert into  MS_ItemUnit ( OrganizationId, ItemId, UnitId, UnitSellingPrice, IsDefault, QuantityInPiece, " +
                         " EnteredBy, EnteredDate, LastUpdatedBy, LastUpdatedDate,IsDeleted, DeletedBy,DeletedDate) " +
                         " values " +
                         "( @OrganizationId, @ItemId, @UnitId, @UnitSellingPrice, @IsDefault, @QuantityInPiece, " +
                         " @EnteredBy, @EnteredDate, 0, null,0, 0,null)";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, itemunit);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
コード例 #2
0
        public bool UpdateItemUnit(MS_ItemUnit itemunit)
        {
            string sql = " Update MS_ItemUnit set  OrganizationId=@OrganizationId, ItemId=@ItemId, UnitId=@UnitId, UnitSellingPrice=@UnitSellingPrice, IsDefault=@IsDefault, QuantityInPiece=@QuantityInPiece, " +
                         " LastUpdatedBy=@LastUpdatedBy, LastUpdatedDate=@LastUpdatedDate,IsDeleted=0" +
                         " where ItemUnitId=@ItemUnitId";

            using (var db = DbHelper.GetDBConnection())
            {
                using (var trsn = new TransactionScope())
                {
                    //db.Execute(sql);
                    var lst = db.Execute(sql, itemunit);
                    trsn.Complete();
                    db.Close();
                    if (lst > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
コード例 #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"));
        }