예제 #1
0
        public int Load(string file)
        {
            int           rows         = 0;
            EProductType  eProductType = null;
            BProductType  bProductType = new BProductType();
            List <string> columns      = new List <string>();
            DataTable     table        = Epplus.ToDataTable(file);

            if (table != null)
            {
                table.Columns["Código"].ColumnName       = "CodeProductType";
                table.Columns["Descripción"].ColumnName  = "Description";
                table.Columns["Código Sunat"].ColumnName = "CodeSunatExistence";
                table.Columns["Estado"].ColumnName       = "State";

                columns = table.GetColumns();

                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    foreach (DataRow datarow in table.Rows)
                    {
                        eProductType = new EProductType(datarow, columns);
                        eProductType.Audit.UserRegister = "User Load";
                        bProductType.Insert(eProductType);

                        rows++;
                    }
                    ts.Complete();
                }
            }
            return(rows);
        }
예제 #2
0
        public ActionResult Add()
        {
            string name = Request.Form["proT"];

            if (string.IsNullOrEmpty(name))
            {
                return(Content(ReturnMsg.empty.ToString()));
            }
            ProductTypeViewModel model = new ProductTypeViewModel();

            model.ProductName = name;
            model.UpdateTime  = DateTime.Now;
            bool isSucc = BProductType.Insert(model);

            if (isSucc)
            {
                return(Content(ReturnMsg.success.ToString()));
            }
            else
            {
                return(Content(ReturnMsg.fail.ToString()));
            }
        }