public static string SaveExportCustom(Excel.Workbook Book, string report_name, bool isXlsFormat = false) { object Missing = System.Reflection.Missing.Value; string str = ""; try { report_name = report_name.Remove(report_name.LastIndexOf('.')); SaveFileDialog sDialog = new SaveFileDialog(); str = string.Format(@"{0}_{1}_{2}", report_name, DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"), DateTime.Now.Ticks); sDialog.Filter = isXlsFormat ? "Microsoft Excel (*.xls)|*.xls" : "Microsoft Excel 2007 (*.xlsx)|*.xlsx"; sDialog.Title = LanguageEngine.GetMessageCaption("000007", ConfigEngine.Language); sDialog.InitialDirectory = Temp; sDialog.FileName = str; if (sDialog.ShowDialog() == DialogResult.OK) { str = sDialog.FileName; Book.SaveAs(str, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Missing, Missing, Missing, Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Missing, Missing, Missing, Missing, Missing); CommonEngine.ShowMessage(ConfigEngine.Language.Equals("vi") ? "Tải tập tin mẫu thành công!" : "Download template success!", MessageType.Success); } } catch (Exception ex) { logger.Error(ex); } return(str); }
private async Task <bool> CheckLogin() { if (string.IsNullOrEmpty(txtUsername.Text)) { CommonEngine.ShowMessage(LanguageEngine.GetMessageCaption("000011", ConfigEngine.Language), MessageType.Error); txtUsername.Focus(); return(false); } if (string.IsNullOrEmpty(txtPassword.Text)) { CommonEngine.ShowMessage(LanguageEngine.GetMessageCaption("000011", ConfigEngine.Language), MessageType.Error); txtPassword.Focus(); return(false); } try { SYS_tblUserDRO user = await UserBUS.CheckLogin(txtUsername.Text.Trim(), EncryptEngine.Encrypt(txtPassword.Text.Trim()), ConfigEngine.Language); if (CommonEngine.CheckValidResponseItem(user.ResponseItem)) { if (user.UserItem != null) { CommonEngine.userInfo = user.UserItem; string temp = user.UserItem.Username.Substring(user.UserItem.Username.IndexOf("|") + 1); user.UserItem.Username = user.UserItem.Username.Replace("|" + temp, ""); CommonEngine.SystemDateTime = Convert.ToDateTime(temp); if (user.UserItem.Locked) { CommonEngine.ShowMessage(LanguageEngine.GetMessageCaption("000010", ConfigEngine.Language).Replace("$UserName$", user.UserItem.Username), MessageType.Error); txtUsername.Focus(); return(false); } } else { CommonEngine.ShowMessage(LanguageEngine.GetMessageCaption("000009", ConfigEngine.Language), MessageType.Error); txtUsername.Focus(); return(false); } } else { return(false); } } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); txtUsername.Focus(); return(false); } return(true); }
private async void btnLogin_Click(object sender, EventArgs e) { if (await CheckLogin()) { string username = (chkRemember.Checked) ? EncryptEngine.Encrypt(txtUsername.Text.Trim()) : ""; string password = (chkRemember.Checked) ? EncryptEngine.Encrypt(txtPassword.Text.Trim()) : ""; IOEngine.Write("Initialize", "Username", username); IOEngine.Write("Initialize", "Password", password); ResponseItem result = await SYS_tblActionLogBUS.InsertUpdateLog(new SYS_tblActionLogDTO { ID = string.Empty, ActionVN = "Đăng Nhập", ActionEN = "Login", ActionTime = DateTime.Now, FunctionID = string.Empty, FunctionNameVN = "Đăng Nhập", FunctionNameEN = "Login", DescriptionEN = string.Format("Account '{0}' has logined to system at {1}.", txtUsername.Text, DateTime.Now), DescriptionVN = string.Format("Tài khoản '{0}' vừa đăng nhập vào hệ thống vào lúc {1}.", txtUsername.Text, DateTime.Now), FullName = CommonEngine.userInfo.FullName, Activity = "Insert", UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language }); if (result.IsError) { CommonEngine.ShowHTTPErrorMessage(result); } else { if (!string.IsNullOrEmpty(result.Message)) { CommonEngine.ShowMessage(result.Message, 0); return; } this.DialogResult = DialogResult.OK; } } }