private bool isValidFile(FileUpload FileUploader) { bool retnVal = false; string extEng = Path.GetFileName(FileUploader.FileName).Substring(Path.GetFileName(FileUploader.FileName).IndexOf(".") + 1, 3); if (FileUploader.HasFile) { if (CommonFuntion.isValidFile(FileUploader.FileBytes, CommonFuntion.FileType.PDF, ".pdf")) { if ((extEng.ToLower() == "pdf")) { retnVal = true; } else { retnVal = false; } } else { retnVal = false; } } else { retnVal = true; } return(retnVal); }
public ActionResult DevelopMessageBoard() { ViewBag.Title = HtmlExtensions.Lang("_Layout_menu_DevMessageBoard"); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); string return_data = ""; t_setting setting = null; InterfaceSettingService setting_service = new SettingService(); try { setting = setting_service.SearchByManagerID(mana_id).FirstOrDefault(); if (setting != null) { return_data = setting.deve_message_board; } } catch { } #if login_debug return_data = "Debug 内容测试"; #endif ViewBag.DATA = JsonConvert.SerializeObject(return_data); return(View()); }
public ActionResult DeleteSummary(int id = 0) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); var json_result = new JsonResult(); InterfaceSummaryService summary_service = new SummaryService(); try { t_summary delete = summary_service.GetByID(id); if (delete != null && delete.mana_id == mana_id) { summary_service.Delete(delete); json_result.Data = new { Result = true, Message = "" }; } else { json_result.Data = new { Result = false, Message = HtmlExtensions.Lang("_Error_Comm_Para") }; } } catch { json_result.Data = new { Result = false, Message = HtmlExtensions.Lang("_Error_Comm_Para") }; } return(json_result); }
public ActionResult SummaryType() { ViewBag.Title = HtmlExtensions.Lang("Financing_SummaryType_Title"); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); List <t_summary> summary_list = new List <t_summary>(); InterfaceSummaryService summary_service = new SummaryService(); try { summary_list = summary_service.SearchByManagerID(mana_id).ToList(); } catch { } #if login_debug t_summary add1 = new t_summary(); add1.mana_id = 1; add1.summ_desc = "123"; add1.summ_id = 1; summary_list.Add(add1); #endif ViewBag.DATA = JsonConvert.SerializeObject(summary_list); return(View()); }
public ActionResult DealRecord(int id = 0) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); var json_result = new JsonResult(); InterfaceSummaryRecordService summary_record_service = new SummaryRecordService(); t_summary_record deal = null; try { deal = summary_record_service.GetByID(id); if (deal != null && deal.mana_id == mana_id) { deal.is_deal = true; summary_record_service.Update(deal); json_result.Data = new { Result = true, Message = "" }; } else { json_result.Data = new { Result = false, Message = HtmlExtensions.Lang("_Error_Comm_Para") }; } } catch { json_result.Data = new { Result = false, Message = HtmlExtensions.Lang("_Error_Comm_Para") }; } return(json_result); }
public ActionResult SaveDevelopMessageBoard(string dev_message) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); InterfaceSettingService setting_service = new SettingService(); try { t_setting setting = setting_service.SearchByManagerID(mana_id).FirstOrDefault(); if (setting == null) { setting = new t_setting(); setting.deve_message_board = dev_message; setting.mana_id = mana_id; setting_service.Insert(setting); } else { setting.deve_message_board = dev_message; setting_service.Update(setting); } } catch { } return(RedirectToAction("DevelopMessageBoard", "System")); }
public ActionResult SearchRecord(string s_date, string e_date, int record_type, int summary) { var json_result = new JsonResult(); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); string check_result = CheckSearchRecord(s_date, e_date, record_type, summary); if (!string.IsNullOrEmpty(check_result)) { json_result.Data = new { Result = false, Message = check_result }; } else { DateTime start_date_datetime = DateTime.Parse(DateTime.Parse(s_date).ToString("yyyy-MM-dd")); DateTime end_date_datetime = DateTime.Parse(DateTime.Parse(e_date).ToString("yyyy-MM-dd")).AddDays(1); List <t_summary_record> search_list = new List <t_summary_record>(); InterfaceSummaryRecordService summary_record_service = new SummaryRecordService(); try { search_list = summary_record_service.Search(mana_id, start_date_datetime, end_date_datetime, record_type, summary) .OrderByDescending(M => M.add_time).ToList(); } catch { } json_result.Data = new { Result = true, Message = CreateShowSummaryRecord(mana_id, search_list) }; } return(json_result); }
public ActionResult RecordDetail() { ViewBag.Title = HtmlExtensions.Lang("Financing_RecordDetail_Title"); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); InterfaceRecordTypeService record_type_service = new RecordTypeService(); InterfaceSummaryService summary_service = new SummaryService(); InterfaceSummaryRecordService summary_record_service = new SummaryRecordService(); List <t_record_type> record_type_list = new List <t_record_type>(); List <t_summary> summary_list = new List <t_summary>(); List <t_summary_record> summary_record_list = new List <t_summary_record>(); try { record_type_list = record_type_service.Table().ToList(); summary_list = summary_service.SearchByManagerID(mana_id).ToList(); summary_record_list = summary_record_service.SearchByManagerID(mana_id).ToList(); } catch { } ViewBag.RECORD_TYPE = JsonConvert.SerializeObject(record_type_list); ViewBag.SUMMARY = JsonConvert.SerializeObject(summary_list); ViewBag.SUMMARY_RECORD = CreateRecordDetailCount(summary_list, summary_record_list); return(View()); }
public virtual void RetrievePageData(int toRowIndex, int needRows) { int iFrom = toRowIndex; mRange.TryGetUnusedRange(ref iFrom, ref needRows); if (needRows <= 0) { return; } string strPageCriteria = GetPageCriteria(iFrom, needRows); TSGetPageDataEventArgs args = new TSGetPageDataEventArgs(strPageCriteria, needRows, mTag); try { OnRetrievePageData(args); } catch (Exception ex) { CommonFuntion.OnDealError(this, ex); } DataTable dtPage = args.PageTable; if (dtPage == null) { mRange.AddRange(iFrom, needRows); return; } mRange.AddRange(iFrom, needRows); MergeToResult(iFrom, needRows, dtPage); }
private bool isValidAttachmentFile(FileUpload FileUploader) { bool isValid = false; if ((FileUploader.HasFile)) { if (CommonFuntion.check_Extensions(FileUploader.FileName)) { Stream fs = null; fs = FileUploader.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] bytfile = br1.ReadBytes(FileUploader.PostedFile.ContentLength); String ext = FileUploader.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (extention.ToLower() == "mp3" || extention.ToLower() == "avi" || extention.ToLower() == "mp4" || extention.ToLower() == "flv" || extention.ToLower() == "mp4" || extention.ToLower() == "mp3") { isValid = true; } else { isValid = false; } } } return(isValid); }
public ActionResult RoleError() { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); if (authentication == null) { return(RedirectToAction("LogOn", "User")); } ViewBag.Title = HtmlExtensions.Lang("System_RoleError_Title"); return(View()); }
private void ResetTime_Button_Click(object sender, RoutedEventArgs e) { string strShutDownTime = ShuDownTime_Edit.Text; Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); cfa.AppSettings.Settings["ShutDownTime"].Value = strShutDownTime; cfa.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); CommonFuntion common = new CommonFuntion(); common.setWindowsShutDown(); }
private bool isValidAttachmentFile(FileUpload FileUploader) { bool isValid = false; if ((FileUploader.HasFile)) { if (CommonFuntion.check_Extensions(FileUploader.FileName)) { Stream fs = null; fs = FileUploader.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] bytfile = br1.ReadBytes(FileUploader.PostedFile.ContentLength); String ext = FileUploader.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Image, FileUploader.PostedFile.ContentType)) { if (extention.ToLower() == "jpg" || extention.ToLower() == "jpeg" || extention.ToLower() == "bmp" || extention.ToLower() == "gif" || extention.ToLower() == "png") { isValid = true; } } else if (CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.PDF, FileUploader.PostedFile.ContentType)) { if (extention.ToLower() == "pdf") { isValid = true; } } else if (CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Video, FileUploader.PostedFile.ContentType)) { if (extention.ToLower() == "avi" || extention.ToLower() == "3gp" || extention.ToLower() == "mp4" || extention.ToLower() == "mpg" || extention.ToLower() == "flv" || extention.ToLower() == "wmv") { isValid = true; } } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Alert", "alert('InValid File');", true); } } } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Alert", "alert('File is InValid');", true); } return(isValid); }
protected void Page_Load(object sender, EventArgs e) { grbThongtinsotiengui.GroupingText = LanguageEngine.Instance().GetContent(LanguageType.TypeUI, "U.HuyDongVon.GiaoDichGuiThem.ucGuiThemTienGuiCT.ThongTinSoTGui"); grbThongtinKhachang.GroupingText = LanguageEngine.Instance().GetContent(LanguageType.TypeUI, "U.HuyDongVon.GiaoDichGuiThem.ucGuiThemTienGuiCT.ThongTinKH"); tbiKiemSoat.GroupingText = LanguageEngine.Instance().GetContent(LanguageType.TypeUI, "U.DungChung.Tab.ThongTinKiemSoat_2"); pnThongtinGiaodich.GroupingText = LanguageEngine.Instance().GetContent(LanguageType.TypeUI, "U.HuyDongVon.GiaoDichGuiThem.ucGuiThemTienGuiCT.ThongTinGD"); cmbGD_HinhThuc.Attributes.Add("onchange", "changehtgd()"); inpTrangThai.Value = CommonFuntion.LayTrangThaiBanGhi(DatabaseConstant.Action.LUU, BusinessConstant.layTrangThaiNghiepVu(sTrangThaiNVu)); if (!IsPostBack) { inpAction.Value = "THEM"; LoadCombobox(); ResetForm(); } }
private bool isValidAttachmentFile(FileUpload FileUploader) { bool isValid = false; HttpPostedFile file = FileUploader.PostedFile; byte[] document = new byte[file.ContentLength]; file.InputStream.Read(document, 0, file.ContentLength); System.UInt32 mimetype; FindMimeFromData(0, null, document, 256, null, 0, out mimetype, 0); System.IntPtr mimeTypePtr = new IntPtr(mimetype); string mime = Marshal.PtrToStringUni(mimeTypePtr); Marshal.FreeCoTaskMem(mimeTypePtr); if (mime == "application/pdf") { if ((FileUploader.HasFile)) { if (CommonFuntion.check_Extensions(FileUploader.FileName)) { Stream fs = null; fs = FileUploader.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] bytfile = br1.ReadBytes(FileUploader.PostedFile.ContentLength); if (CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Image, FileUploader.PostedFile.ContentType)) { isValid = true; } else { isValid = false; ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Alert", "alert('Image file is in wrong format.');", true); } } } } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Alert", "alert('Image file is in wrong format.');", true); } return(isValid); }
protected void Application_Error(Object sender, EventArgs e) { #region 记录错误 Exception ex = Server.GetLastError().GetBaseException(); StringBuilder str = new StringBuilder(); str.Append("\r\n.客户信息:"); string ip = ""; if (Request.ServerVariables.Get("HTTP_X_FORWARDED_FOR") != null) { ip = Request.ServerVariables.Get("HTTP_X_FORWARDED_FOR").ToString().Trim(); } else { ip = Request.ServerVariables.Get("Remote_Addr").ToString().Trim(); } str.Append("\r\n\tIp:" + ip); str.Append("\r\n\t浏览器:" + Request.Browser.Browser.ToString()); str.Append("\r\n\t浏览器版本:" + Request.Browser.MajorVersion.ToString()); str.Append("\r\n\t操作系统:" + Request.Browser.Platform.ToString()); str.Append("\r\n.错误信息:"); str.Append("\r\n\t页面:" + Request.Url.ToString()); str.Append("\r\n\t错误信息:" + ex.Message); str.Append("\r\n\t错误源:" + ex.Source); str.Append("\r\n\t异常方法:" + ex.TargetSite); str.Append("\r\n\t堆栈信息:" + ex.StackTrace); str.Append("\r\n--------------------------------------------------------------------------------------------------"); Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(str.ToString()); #endregion #region 跳转到错误友好页面(400,500) HttpException httpex = ex as HttpException; int httpStatusCode = httpex != null?httpex.GetHttpCode() : 500; if (httpStatusCode == 404) { Response.Redirect("~/" + CommonFuntion.LangCode() + "/System/PageNotFound"); } else if (httpStatusCode == 500) { Response.Redirect("~/" + CommonFuntion.LangCode() + "/System/PageError"); } #endregion }
private t_summary_record CreateSummaryRecord(AddRecordModel model, decimal record_amount, decimal tran_record_amount, bool is_deal) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); t_summary_record insert = new t_summary_record(); insert.mana_id = mana_id; insert.reco_type_code = model.record_type_code; insert.summ_id = model.summary_id; insert.summ_tran_id = model.summary_transfer_id; insert.loan_type_code = model.loan_type_code; insert.amount = record_amount; insert.tran_amount = tran_record_amount; insert.remark = model.remark == null ? "" : model.remark.Trim(); insert.add_time = model.add_time; insert.is_deal = is_deal; return(insert); }
public ActionResult SummaryType(AddSummaryTypeModel model) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); string check_result = CheckSummary(model); if (!string.IsNullOrEmpty(check_result)) { ViewBag.SubmitError = check_result; } InterfaceSummaryService summary_service = new SummaryService(); if (ModelState.IsValid && string.IsNullOrEmpty(check_result)) { t_summary add_summary = new t_summary(); add_summary.summ_desc = model.add_summary; add_summary.mana_id = mana_id; add_summary.sort_by = 10000; try { summary_service.Insert(add_summary); } catch { } } else { List <t_summary> summary_list = new List <t_summary>(); try { summary_list = summary_service.SearchByManagerID(mana_id).ToList(); } catch { } ViewBag.DATA = JsonConvert.SerializeObject(summary_list); return(View()); } return(RedirectToAction("SummaryType", "Financing")); }
public ActionResult NotDealLoan() { var json_result = new JsonResult(); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); InterfaceSummaryRecordService summary_record_service = new SummaryRecordService(); List <t_summary_record> search_list = new List <t_summary_record>(); try { search_list = summary_record_service.NotDealLoan(mana_id).OrderByDescending(M => M.add_time).ToList(); } catch { } json_result.Data = new { Result = true, Message = CreateShowSummaryRecord(mana_id, search_list) }; return(json_result); }
/// <summary> /// 重写控制器方法Action执行前判断 /// </summary> /// <param name="filterContext"></param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); #region 设置语言码和保存到cookies //获取URL中的语言字符串 string lang = filterContext.RouteData.Values["lang"].ToString().ToLower(); string encodingLang = ""; HttpCookie langCookie = Request.Cookies["PresentLang"]; //查看url里面语言码是否错误 if (!WebCont.STA_ALL_LANG.Contains(lang)) { if (langCookie != null) { lang = CommonFuntion.StringDecoding(langCookie.Value); } else { lang = WebCont.DEFAULT_LANG; } } filterContext.RouteData.Values["lang"] = lang; encodingLang = CommonFuntion.StringEncoding(lang); //保存到cookies if (langCookie == null) { langCookie = new HttpCookie("PresentLang"); langCookie.Value = encodingLang; langCookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(langCookie); } else if (langCookie.Value != encodingLang) { Request.Cookies["PresentLang"].Value = encodingLang; Response.Cookies["PresentLang"].Value = encodingLang; Response.Cookies["PresentLang"].Expires = DateTime.Now.AddDays(1); } #endregion }
private bool isValidAttachmentFile(FileUpload FileUploader) { bool isValid = false; if ((FileUploader.HasFile)) { if (CommonFuntion.check_Extensions(FileUploader.FileName)) { Stream fs = null; fs = FileUploader.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] bytes = FileUploader.FileBytes; if (CommonFuntion.isValidFile(bytes, CommonFuntion.FileType.Image, FileUploader.PostedFile.ContentType)) { String ext = FileUploader.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (extention.ToLower() == "jpg" || extention.ToLower() == "jpeg" || extention.ToLower() == "bmp" || extention.ToLower() == "gif" || extention.ToLower() == "png" || extention.ToLower() == "jpe") { isValid = true; } else { isValid = false; } } else { isValid = false; } } else { } } return(isValid); }
public ActionResult RecordAdjust() { ViewBag.Title = HtmlExtensions.Lang("Financing_RecordAdjust_Title"); FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); InterfaceSummaryService summary_service = new SummaryService(); InterfaceSummaryRecordService summary_record_service = new SummaryRecordService(); List <t_summary> summary_list = new List <t_summary>(); List <t_summary_record> summary_record_list = new List <t_summary_record>(); try { summary_list = summary_service.SearchByManagerID(mana_id).ToList(); summary_record_list = summary_record_service.SearchByManagerID(mana_id).ToList(); } catch { } ViewBag.DATA = CreateRecordAdjustCount(summary_list, summary_record_list); return(View()); }
protected void btnAddPhoto_Click(object sender, EventArgs e) { int result = 0; string ext = null;; byte[] t_Image = null; Double FileSize = 0; if ((ddlAlbum.SelectedValue == "0") || (ddlSubalbum.SelectedValue == "0" || ddlSubalbum.SelectedValue == "") || (txtPhoto.Text == "") || (!PhotoUpload.HasFile)) { ScriptManager.RegisterStartupScript(this, typeof(Page), "msg", "alert('All fields are mandatory!');", true); return; } if (CheckValidPhoto() < 1) { return; } HttpFileCollection fileCollection = Request.Files; if (PhotoUpload.HasFile) { if (isValidAttachmentFile(PhotoUpload)) { ext = System.IO.Path.GetExtension(PhotoUpload.FileName); t_Image = PhotoUpload.FileBytes; FileSize = PhotoUpload.PostedFile.ContentLength / 1024; } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "msg", "alert('File Invalid');", true);; return; } FileInfo file = new FileInfo(PhotoUpload.FileName); Bitmap img = new Bitmap(PhotoUpload.FileContent); var imageHeight = img.Height; var imageWidth = img.Width; if (imageHeight != 420 && imageWidth != 640) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Photograph should fall between 420 to 640 pixels.')", true); return; } } for (int i = 0; i < fileCollection.Count; i++) { HttpPostedFile uploadfile1 = fileCollection[i]; string fileNames = Path.GetFileName(uploadfile1.FileName); if (CommonFuntion.check_Extensions(fileNames) == true) { if (uploadfile1.ContentLength > 0) { ext = fileNames.ToString(); String extention = ext.Substring(ext.IndexOf(".") + 1, 3); SqlCommand t_SQLCmd = new SqlCommand(); String strSQL = string.Empty; string filename = string.Empty; filename = fileNames; filename = filename.Substring(0, filename.IndexOf('.')) + "_" + System.DateTime.Now.ToString().Replace("/", "_") + System.IO.Path.GetExtension(fileNames); filename = filename.Replace(":", "_"); uploadfile1.SaveAs(Server.MapPath("../../App/PhotoAlbum/" + fileNames)); // fileCollection[i])); objAlbumSchema.Actiontype = "Insert"; objAlbumSchema.Name = txtPhoto.Text.ToString(); objAlbumSchema.PhotoSubAlbumID = Convert.ToInt32(ddlSubalbum.SelectedValue); objAlbumSchema.Filename = fileNames; int isinsert = objAlbumBL.DMLAlbumDetails(objAlbumSchema); BindPhoto(); } } } if (result == 1) { ScriptManager.RegisterStartupScript(this, typeof(Page), "msg", "alert('Save SucessFully');", true); } }
protected void btnSave_Click(object sender, EventArgs e) // Anand :- UspDMLMenuMaster { try { if (drpMenuCategory.SelectedValue == "0") { ScriptManager.RegisterStartupScript(this, typeof(Page), "message", "alert('Please Select Menu Category!!')", true); } else { SqlCommand t_SQLCmd = new SqlCommand(); byte[] t_Image = new byte[fileMenu.PostedFile.ContentLength]; HttpPostedFile t_ImageReader = fileMenu.PostedFile; t_ImageReader.InputStream.Read(t_Image, 0, (int)fileMenu.PostedFile.ContentLength); objMenuSchema.MenuName = txtMenuName.Text; objMenuSchema.MenuName_LL = txtMenuName_LL.Text; objMenuSchema.MenuName_UL = txtMenuName_UL.Text; objMenuSchema.IsNewflag = chkIsNew.Checked; objMenuSchema.Active = chkActive.Checked; objMenuSchema.IsEternalLink = chkNewTab.Checked; objMenuSchema.MetaDescription = txtMDesc.Text; objMenuSchema.MetaDescription_LL = txtMDesc_LL.Text; objMenuSchema.MetaDescription_UL = txtMDesc_UL.Text; objMenuSchema.MetaKeywords = txtMKeywords.Text; objMenuSchema.MetaKeywords_LL = txtMKeyWords_LL.Text; objMenuSchema.MetaKeywords_UL = txtMKeyWords_UL.Text; objMenuSchema.MenuImage = t_Image; objMenuSchema.SequenceNo = Convert.ToInt32(txtSequence.Text); objMenuSchema.MenuCategory = drpMenuCategory.SelectedValue; objMenuSchema.MenuType = Convert.ToInt32(drpMenuType.SelectedValue); objMenuSchema.MenuTypeValue = txtMTValue.Text; if (drpMenu.SelectedValue != "0") { if (drpSubMenu.SelectedValue != "0" && drpSubMenu.SelectedValue.Trim() != "") { objMenuSchema.Parentid = Convert.ToInt32(drpSubMenu.SelectedValue); } else { objMenuSchema.Parentid = Convert.ToInt32(drpMenu.SelectedValue); } } else { objMenuSchema.Parentid = Convert.ToInt32(drpMenu.SelectedValue); } //t_SQLCmd.Parameters.Add("@RoleID", SqlDbType.UniqueIdentifier); //t_SQLCmd.Parameters["@RoleID"].Value = DBNull.Value; //t_SQLCmd.Parameters.Add("@CreatedBy", SqlDbType.Int); //t_SQLCmd.Parameters["@CreatedBy"].Value = DBNull.Value; objMenuSchema.PageHeading = txtPageHead.Text; objMenuSchema.PageHeading_LL = txtPageHead_LL.Text; objMenuSchema.PageHeading_UL = txtPageHead_UL.Text; objMenuSchema.PageTitle = txtPageTitle.Text; objMenuSchema.PageTitle_LL = txtPageTitle_LL.Text; objMenuSchema.PageTitle_UL = txtPageTitle_UL.Text; objMenuSchema.ForMobileVersion = chkmobileversion.Checked; if (Request.QueryString["action"] == "edit") { valueid = Request.QueryString["shvid"]; //t_SQLCmd.Parameters.Add("@MenuID", SqlDbType.Int); //t_SQLCmd.Parameters["@MenuID"].Value = valueid; objMenuSchema.Menuid = Convert.ToInt32(valueid); if (fileMenu.HasFile) { string filenameExt = fileMenu.FileName; string fileExt = System.IO.Path.GetExtension(fileMenu.FileName); objMenuSchema.FileExt = fileExt; if (fileExt == ".jpeg" || fileExt == ".jpg" || fileExt == ".PNG" || fileExt == ".png" || fileExt == ".bmp" || fileExt == ".tiff") { if (CommonFuntion.check_Extensions(filenameExt)) { Stream fs = null; fs = fileMenu.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] filebytes = fileMenu.FileBytes; if (CommonFuntion.isValidFile(filebytes, CommonFuntion.FileType.Image, fileMenu.PostedFile.ContentType)) { String ext = fileMenu.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (extention.ToLower() == "jpg" || extention.ToLower() == "jpeg" || extention.ToLower() == "bmp" || extention.ToLower() == "gif" || extention.ToLower() == "png") { objMenuSchema.ActionType = "edit"; result = ObjmenuBL.SaveMenuDeatails(objMenuSchema); if (result != 0) { Clear(); lblerror.Text = ""; ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Data saved Successfully !!!');window.location.href='MenuList.aspx'", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Error !!!')", true); } } } else { lblerror.Text = "Please Upload Image File only"; } } else { lblerror.Text = "Please Upload Image File only"; } } else { lblerror.Text = "Please Upload Image File only"; } } else { objMenuSchema.ActionType = "edit"; result = ObjmenuBL.SaveMenuDeatails(objMenuSchema); if (result != 0) { Clear(); lblerror.Text = ""; ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Data saved Successfully !!!');window.location.href='MenuList.aspx'", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Error !!!')", true); } } } else { if (fileMenu.HasFile) { Stream fs = null; fs = fileMenu.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); string filenameExt = fileMenu.FileName; string fileExt = System.IO.Path.GetExtension(fileMenu.FileName); objMenuSchema.FileExt = fileExt; if (fileExt == ".jpeg" || fileExt == ".jpg" || fileExt == ".PNG" || fileExt == ".png" || fileExt == ".bmp" || fileExt == ".tiff") { byte[] pdffile = fileMenu.FileBytes; if (CommonFuntion.check_Extensions(filenameExt)) { if (CommonFuntion.isValidFile(pdffile, CommonFuntion.FileType.Image, fileMenu.PostedFile.ContentType)) { String ext = fileMenu.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (extention.ToLower() == "jpg" || extention.ToLower() == "jpeg" || extention.ToLower() == "bmp" || extention.ToLower() == "gif" || extention.ToLower() == "png") { objMenuSchema.ActionType = "Insert"; result = ObjmenuBL.SaveMenuDeatails(objMenuSchema); if (result != 0) { Clear(); lblerror.Text = ""; ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Data saved Successfully !!!');window.location.href='MenuList.aspx'", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Error !!!')", true); } } } else { lblerror.Text = "Please Upload Image File only"; } } else { lblerror.Text = "Please Upload Image File only"; } } else { lblerror.Text = "Please Upload Image File only"; } } else { objMenuSchema.ActionType = "Insert"; result = ObjmenuBL.SaveMenuDeatails(objMenuSchema); if (result != 0) { Clear(); lblerror.Text = ""; ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Data saved Successfully !!!');window.location.href='MenuList.aspx'", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Error !!!')", true); } } } } } catch (Exception ee) { throw ee; } }
protected void btnSave_Click(object sender, EventArgs e) { try { string ext = null;; byte[] t_Image = null; Double FileSize = 0; if (ddlFileType.SelectedIndex == 1) { videopath = Server.MapPath("../../Site/Upload/Video/Motivational/"); } else { videopath = Server.MapPath("../../Site/Upload/Video/SuccessStories/"); } if (uploadVideo.HasFile) { string videofile = uploadVideo.FileName; double filesize = (double)uploadVideo.FileBytes.Length; double fileinMB = filesize / (1024 * 1024); } //if (ddlFileType.SelectedValue == "1") //{ // if (uploadVideo.HasFile) // { // string fileextension = System.IO.Path.GetExtension(uploadVideo.FileName); // if (fileextension.ToUpper() != ".MP3") // { // ClientScript.RegisterClientScriptBlock(this.GetType(), "Message", "alert('Invalid Audio File');", true); // uploadVideo.Focus(); // return; // } // } //} if (ddlFileType.SelectedValue == "1" || ddlFileType.SelectedValue == "2") { Stream fs = null; fs = uploadVideo.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] bytes = br1.ReadBytes(uploadVideo.PostedFile.ContentLength); if (CommonFuntion.isValidFile(bytes, CommonFuntion.FileType.Video, uploadVideo.PostedFile.ContentType)) { String extention = Path.GetExtension(uploadVideo.FileName); } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Alert", "alert('File Is InValid , Kindly Upload avi/mpg/mpg/flv/wmv/mp4 Formatted file.');", true); return; } } if (uploadImage.HasFile) { if (uploadImage.HasFile) { if (isValidAttachmentPhoto(uploadImage)) { ext = System.IO.Path.GetExtension(uploadImage.FileName); t_Image = uploadImage.FileBytes; FileSize = uploadImage.PostedFile.ContentLength / 1024; if (Convert.ToInt32(SavetoDB()) == 1) { ext = uploadImage.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (extention.ToLower() == "jpg" || extention.ToLower() == "jpeg" || extention.ToLower() == "bmp" || extention.ToLower() == "gif" || extention.ToLower() == "png") { uploadImage.PostedFile.SaveAs(videopath + uploadImage.FileName); uploadVideo.PostedFile.SaveAs(videopath + uploadVideo.FileName); ddlFileType.SelectedValue = "Select"; ClearControls(); ClientScript.RegisterClientScriptBlock(this.GetType(), "Message", "alert('Upload File Successfully');", true); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "Message", "alert('Invalid Image File!!!!');", true); } } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "msg", "alert('Invalid Image File');", true);; return; } } } } catch (Exception ex) { throw ex; } finally { } }
public ActionResult RecordAdjust(AdjustRecordModel model) { FormsAuthenticationTicket authentication = CommonFuntion.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); InterfaceSummaryRecordService summary_record_service = new SummaryRecordService(); if (ModelState.IsValid) { string check_result = CheckRecordAdjust(mana_id, model); if (!string.IsNullOrEmpty(check_result)) { return(Content(ReturnMessageAndRedirect(check_result, "Financing", "RecordAdjust"))); } else { List <t_summary_record> summary_record_list = new List <t_summary_record>(); try { summary_record_list = summary_record_service.SearchByManagerID(mana_id).ToList(); } catch {} for (int i = 0; i < model.summ_id.Count(); i++) { int id = model.summ_id[i]; decimal summ_total_amount = CalAmount(id, summary_record_list); decimal adjust_amount = model.adjust_amont[i]; //如果调整数和数据库记录数不一致,则需要插入数据 decimal diff = adjust_amount - summ_total_amount; if (diff != 0) { t_summary_record insert = new t_summary_record(); insert.mana_id = mana_id; insert.summ_id = id; insert.summ_tran_id = 0; insert.loan_type_code = 0; insert.amount = diff; insert.tran_amount = 0; insert.remark = "AUTO"; insert.add_time = DateTime.Now; insert.is_deal = true; if (diff > 0) { insert.reco_type_code = WebCont.RECORD_TYPE_INCOME; } else { insert.reco_type_code = WebCont.RECORD_TYPE_PAY; } try { summary_record_service.DelayInsert(insert); } catch { } } } try { summary_record_service.DelaySubmit(); } catch { } } } return(RedirectToAction("RecordAdjust", "Financing")); }
private void setWindowsShutDown() { CommonFuntion pCommon = new CommonFuntion(); pCommon.setWindowsShutDown(); }
private bool SaveUpload() { bool retnVal = false; lblmsg.Text = ""; lblmsg.Text = ""; int result = 0; HttpFileCollection fileCollection = Request.Files; for (int i = 0; i < fileCollection.Count; i++) { HttpPostedFile uploadfile1 = fileCollection[i]; Stream fs = null; fs = uploadfile1.InputStream;// PhotoUpload.PostedFile.InputStream; BinaryReader br1 = new BinaryReader(fs); byte[] bytfile = br1.ReadBytes(fileCollection[i].ContentLength); if (CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Image, ".jpg") || CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Image, ".bmp") || CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Image, ".jpeg") || CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Image, ".png") || CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.PDF, ".pdf") || CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Video, ".mp3") || CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Video, ".mp4") || CommonFuntion.isValidFile(bytfile, CommonFuntion.FileType.Video, ".avi")) { result = 1; } else { return(false); } } for (int i = 0; i < fileCollection.Count; i++) { HttpPostedFile uploadfile1 = fileCollection[i]; string fileNames = Path.GetFileName(uploadfile1.FileName); if (CommonFuntion.check_Extensions(fileNames) == true) { if (uploadfile1.ContentLength > 0) { string ext = fileNames.ToString(); String extention = ext.Substring(ext.IndexOf(".") + 1, 3); SqlCommand t_SQLCmd = new SqlCommand(); String strSQL = string.Empty; string filename = string.Empty; filename = fileNames; filename = filename.Substring(0, filename.IndexOf('.')) + "_" + System.DateTime.Now.ToString().Replace("/", "_") + System.IO.Path.GetExtension(fileNames); filename = filename.Replace(":", "_"); if (extention.ToLower() == "pdf") { uploadfile1.SaveAs(Server.MapPath("../../Site/Upload/Pdf/" + fileNames)); } else if (extention.ToLower() == "jpg" || extention.ToLower() == "bmp" || extention.ToLower() == "jpeg" || extention.ToLower() == "png") { uploadfile1.SaveAs(Server.MapPath("../../Site/Upload/Images/" + fileNames)); } else if (extention.ToLower() == "mp4" || extention.ToLower() == "mp3" || extention.ToLower() == "avi" || extention.ToLower() == "png") { uploadfile1.SaveAs(Server.MapPath("../../Site/Upload/Video/" + fileNames)); } } } } if (result == 1) { retnVal = true; } return(retnVal); }
protected void btnAddAlbumPhoto_Click(object sender, EventArgs e) { if ((txtAlbum.Text == "") || (!AlbumPhotoUpload.HasFile)) { ScriptManager.RegisterStartupScript(this, typeof(Page), "msg", "alert('All fields are mandatory!');", true); txtAlbum.Focus(); return; } if (CheckValidAlbum() < 1) { return; } string InsertMode = string.Empty; int isinsert = 0; if (AlbumPhotoUpload.HasFile) { if (CommonFuntion.isValidFile(AlbumPhotoUpload.FileBytes, CommonFuntion.FileType.Image, AlbumPhotoUpload.PostedFile.ContentType)) { String ext = AlbumPhotoUpload.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (extention.ToLower() == "jpg" || extention.ToLower() == "jpeg" || extention.ToLower() == "bmp" || extention.ToLower() == "gif" || extention.ToLower() == "png") { } else { return; } } else { return; } } string filename = AlbumPhotoUpload.FileName; filename = filename.Substring(0, filename.IndexOf('.')) + "_" + System.DateTime.Now.ToString().Replace("/", "_") + System.IO.Path.GetExtension(AlbumPhotoUpload.FileName); filename = filename.Replace(":", "_"); AlbumPhotoUpload.SaveAs(Server.MapPath("..\\PhotoAlbum") + "\\" + filename); InsertMode = Convert.ToString(ViewState["_Status"]).ToLower(); switch (InsertMode) { case "album": objViewPhotoAlbumSchema.ActionType = "album"; objViewPhotoAlbumSchema.Albumname = txtAlbum.Text.ToString(); objViewPhotoAlbumSchema.FileName = filename; isinsert = objViewPhotoAlbumBL.DMLAlbumPhoto(objViewPhotoAlbumSchema); if (isinsert > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "msg", "alert('Album Created!');", true); Server.Transfer("FrmCreateAlbum.aspx", false); } break; case "subalbum": objViewPhotoAlbumSchema.ActionType = "subalbum"; objViewPhotoAlbumSchema.Albumname = txtAlbum.Text.ToString(); objViewPhotoAlbumSchema.FileName = filename; objViewPhotoAlbumSchema.Photoalbumid = Convert.ToInt32(ViewState["_id"]); isinsert = objViewPhotoAlbumBL.DMLAlbumPhoto(objViewPhotoAlbumSchema); if (isinsert > 0) { ScriptManager.RegisterStartupScript(this, typeof(Page), "msg", "alert('Sub Album Created!');", true); Server.Transfer("FrmCreateAlbum.aspx", false); } break; } }
private bool isValidAttachmentFile(FileUpload FileUploader) { bool isValid = false; HttpPostedFile file = FileUploader.PostedFile; byte[] document = new byte[file.ContentLength]; file.InputStream.Read(document, 0, file.ContentLength); UInt32 mimeType = default(UInt32); FindMimeFromData(0, null, document, 256, null, 0, out mimeType, 0); IntPtr mimeTypePtr = new IntPtr(mimeType); string mime = Marshal.PtrToStringUni(mimeTypePtr); Marshal.FreeCoTaskMem(mimeTypePtr); if (knownTypes == null || mimeTypes == null) { InitializeMimeTypeLists(); } string contentType = ""; string extension = System.IO.Path.GetExtension(FileUploader.FileName).Replace(".", "").ToLower(); mimeTypes.TryGetValue(extension, out contentType); mime = contentType; if (mime == "image/jpeg" || mime == "image/bmp" || mime == "image/gif" || mime == "image/png") { if ((FileUploader.HasFile)) { if (CommonFuntion.check_Extensions(FileUploader.FileName)) { //Stream fs = null; //fs = FileUploader.PostedFile.InputStream; //BinaryReader br1 = new BinaryReader(fs); //byte[] bytfile = br1.ReadBytes(Convert.ToInt32(fs.Length)); Stream fs = FileUploader.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); //byte[] bytfile = new byte[FileUploader.FileContent.Length]; byte[] bytes = FileUploader.FileBytes; if (CommonFuntion.isValidFile(bytes, CommonFuntion.FileType.Image, FileUploader.PostedFile.ContentType)) { String ext = FileUploader.FileName; String extention = ext.Substring(ext.IndexOf(".") + 1, 3); if (extention.ToLower() == "jpg" || extention.ToLower() == "jpeg" || extention.ToLower() == "bmp" || extention.ToLower() == "gif" || extention.ToLower() == "png") { isValid = true; } else { isValid = false; } } else { isValid = false; } } else { } } } return(isValid); }