//filename : use filename from control
        //documentTypeId : use id of table(type)
        //ctrl : use ASPxUploadControl from webpage
        //return path for save file
        public string UploadFile(string fileName, int documentTypeId, ASPxUploadControl ctrl)
        {
            string dir = "~/Documents/" + HttpContext.Current.Session["userName"] + "/" + documentTypeId + "/";
            bool isExist = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(dir));
            if (!isExist)
            {
                System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(dir));
            }

            Document x = new Document();
            x.Path = dir + fileName;
            x.IdentityId = Convert.ToInt32(HttpContext.Current.Session["id"]);
            x.DocumentTypeId = documentTypeId;
            x.FileName = fileName;
            db.Documents.InsertOnSubmit(x);
            db.SubmitChanges();

            return dir;
        }
 partial void UpdateDocument(Document instance);
 partial void DeleteDocument(Document instance);
 partial void InsertDocument(Document instance);