Exemplo n.º 1
0
        protected override ResultMessage Save_Create()
        {
            var bl    = new SupplierBL();
            int newID = 0;

            var rm = bl.Insert(this.Current, out newID);

            if (rm.Result)
            {
                this.Current.SupplierID = newID;
                this.Original           = CopyEntity(this.Current);
            }

            return(rm);
        }
Exemplo n.º 2
0
 public ActionResult Register(SupplierInfo supplierinfo)
 {
     try
     {
         SupplierBL _bl = new SupplierBL();
         supplierinfo.Created_by   = "";
         supplierinfo.Created_date = DateTime.Now;
         decimal ck = _bl.Insert(supplierinfo);
         return(Json(new { success = ck }));
     }
     catch (Exception ex)
     {
         NaviCommon.Common.log.Error(ex.ToString());
         return(Json(new { success = "-1" }));
     }
 }
Exemplo n.º 3
0
        public Decimal Import_file_excel(HttpPostedFileBase fileImport)
        {
            try
            {
                DataSet _ds = new DataSet();
                if (fileImport != null && fileImport.ContentLength > 0)
                {
                    if (!fileImport.FileName.EndsWith(".xls") && !fileImport.FileName.EndsWith(".xlsx"))
                    {
                        return(-3);
                    }
                    else
                    {
                        Stream           stream = fileImport.InputStream;
                        IExcelDataReader reader = null;

                        if (fileImport.FileName.EndsWith(".xls"))
                        {
                            reader = ExcelReaderFactory.CreateBinaryReader(stream);
                        }
                        else if (fileImport.FileName.EndsWith(".xlsx"))
                        {
                            reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                        }

                        _ds = reader.AsDataSet();
                        reader.Close();
                    }
                }
                if (_ds != null)
                {
                    _ds.Tables[0].Rows[0].Delete();//xóa dòng title
                    _ds.AcceptChanges();
                    if (_ds.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in _ds.Tables[0].Rows)
                        {
                            SupplierInfo obj_info = new SupplierInfo();
                            obj_info.Name         = dr[0] == null ? "" : dr[0].ToString();
                            obj_info.Code         = dr[1] == null ? "" : dr[1].ToString();
                            obj_info.Phone        = dr[2] == null ? "" : dr[2].ToString();
                            obj_info.Fax          = dr[3] == null ? "" : dr[3].ToString();
                            obj_info.Email        = dr[4] == null ? "" : dr[4].ToString();
                            obj_info.Notes        = dr[5] == null ? "" : dr[5].ToString();
                            obj_info.Created_date = DateTime.Now;
                            obj_info.Created_by   = "";
                            SupplierBL _bl = new SupplierBL();
                            _bl.Insert(obj_info);
                        }
                    }
                    else
                    {
                        return(-4);//không có dữ liệu
                    }
                }
                return(1);
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(-1);
            }
        }