private void bbiExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { string pathFile = new ObjSet.Folder(@"C:\MDS\Export\").GetPath() + "CurrencyList_" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx"; gvCurrency.ExportToXlsx(pathFile); System.Diagnostics.Process.Start(pathFile); }
private void bbiExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (tabbedControlGroup1.SelectedTabPage == layoutControlGroup1) //Excel { IWorkbook workbook = spsVessel.Document; string pathFile = new ObjSet.Folder(@"C:\MDS\Export\").GetPath() + slueCarrier.Text.Trim().Replace(" ", "_") + "-" + speYear.Value.ToString() + "-" + speTime.Value.ToString() + ".xlsx"; using (FileStream stream = new FileStream(pathFile, FileMode.Create, FileAccess.ReadWrite)) { workbook.SaveDocument(stream, DocumentFormat.Xlsx); System.Diagnostics.Process.Start(pathFile); } } else //GridControl { string pathFile = new ObjSet.Folder(@"C:\MDS\Export\").GetPath() + "VesselList_" + slueCarrier.Text.Trim().Replace(" ", "_") + "-" + speYear.Value.ToString() + "-" + speTime.Value.ToString() + "-" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx"; gvVessel.ExportToXlsx(pathFile); System.Diagnostics.Process.Start(pathFile); } }
private void bbiSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { txeID.Focus(); if (glueGroup.Text.Trim() == "") { FUNC.msgWarning("Please select function group."); glueGroup.Focus(); } else if (txeCode.Text.Trim() == "") { FUNC.msgWarning("Please input function code."); txeCode.Focus(); } else if (txeName.Text.Trim() == "") { FUNC.msgWarning("Please input function name."); txeName.Focus(); } else if (txeVersion.ErrorText != "") { FUNC.msgWarning("Please input version."); txeVersion.Focus(); } else if (txeBrowse.Text.Trim() == "") { FUNC.msgWarning("Please input function file."); txeBrowse.Focus(); } else { if (FUNC.msgQuiz("Confirm save data ?") == true) { StringBuilder sbSQL = new StringBuilder(); string strCREATE = "0"; if (txeCREATE.Text.Trim() != "") { strCREATE = txeCREATE.Text.Trim(); } string Status = "NULL"; if (rgStatus.SelectedIndex != -1) { Status = rgStatus.Properties.Items[rgStatus.SelectedIndex].Value.ToString(); } if (lblStatus.Text == "* Add Function") { string newFileName = new ObjSet.Folder(pathDrive + txeCode.Text.ToUpper().Trim()).GetPath() + txeCode.Text.ToUpper().Trim() + "_" + txeVersion.Text.Trim(); //CopyFile if (txeBrowse.Text.Trim() != "") { System.IO.FileInfo fi = new System.IO.FileInfo(txeBrowse.Text); string extn = fi.Extension; newFileName += extn; System.IO.File.Copy(txeBrowse.Text.Trim(), newFileName); } sbSQL.Append(" INSERT INTO FunctionList(FunctionNo, FunctionName, Version, GroupFunction, Status, PathFile, CreateBy, CreateDate) "); sbSQL.Append(" VALUES(N'" + txeCode.Text.Trim().Replace("'", "''") + "', N'" + txeName.Text.Trim().Replace("'", "''") + "', N'" + txeVersion.Text.Trim() + "', '" + glueGroup.EditValue.ToString() + "', " + Status + ", '" + newFileName + "', '" + strCREATE + "', GETDATE()) "); } else if (lblStatus.Text == "* Edit Function") { StringBuilder sbCHK_FILE = new StringBuilder(); sbCHK_FILE.Append("SELECT PathFile FROM FunctionList WHERE (OIDFunction = '" + txeID.Text.Trim() + "') "); string chkFILE = new DBQuery(sbCHK_FILE).getString(); string newFileName = ""; if (chkFILE != txeBrowse.Text.Trim()) { newFileName = new ObjSet.Folder(pathDrive + txeCode.Text.ToUpper().Trim()).GetPath() + txeCode.Text.ToUpper().Trim() + "_" + txeVersion.Text.Trim(); //CopyFile System.IO.FileInfo fi = new System.IO.FileInfo(txeBrowse.Text); string extn = fi.Extension; newFileName += extn; System.IO.File.Copy(txeBrowse.Text.Trim(), newFileName); } sbSQL.Append(" UPDATE FunctionList SET "); sbSQL.Append(" FunctionNo=N'" + txeCode.Text.ToUpper().Trim().Replace("'", "''") + "', "); sbSQL.Append(" FunctionName=N'" + txeName.Text.Trim().Replace("'", "''") + "', "); sbSQL.Append(" Version=N'" + txeVersion.Text.Trim() + "', "); sbSQL.Append(" GroupFunction='" + glueGroup.EditValue.ToString() + "', "); if (newFileName != "") { sbSQL.Append(" PathFile='" + newFileName + "', "); } sbSQL.Append(" Status=" + Status + " "); sbSQL.Append(" WHERE (OIDFunction = '" + txeID.Text.Trim() + "') "); } //MessageBox.Show(sbSQL.ToString()); if (sbSQL.Length > 0) { try { bool chkSAVE = new DBQuery(sbSQL).runSQL(); if (chkSAVE == true) { FUNC.msgInfo("Save complete."); bbiNew.PerformClick(); } } catch (Exception) { } } } } }