예제 #1
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"));
        }