//tạo chứng nhận chất lượng public static void Create_CNCL(object filename, object SaveAs, string idContract, string pOnumber, string KHMS, string idNTKT, float Nod) { WordOffice.Application wordApp = new WordOffice.Application(); object missing = Missing.Value; WordOffice.Document myWordDoc = null; try { if (File.Exists((string)filename)) { object readOnly = false; object isVisible = false; wordApp.Visible = false; myWordDoc = wordApp.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); myWordDoc.Activate(); NTKT nTKT = new NTKT(); int ret = nTKT.GetObjectNTKT(idNTKT, ref nTKT); //find and replace FindAndReplace(wordApp, "<Contract_ID>", " " + idContract + " "); FindAndReplace(wordApp, "<PO_Number>", " " + pOnumber + " "); FindAndReplace(wordApp, "<KHMS>", " " + KHMS + " "); FindAndReplace(wordApp, "<Total>", " " + (Nod).ToString() + " "); FindAndReplace(wordApp, "<NofDe>", " " + (Nod - Math.Round((Nod) * 0.02)).ToString() + " "); FindAndReplace(wordApp, "<BHD>", " " + Math.Round((Nod) * 0.02).ToString() + " "); string[] dateNow = convertDateFormat.ConvertFormatDate(DateTime.Now.ToString("dd-MM-yyyy"), "dd-MM-yyyy", "dd/MM/yyyy"); FindAndReplace(wordApp, "<dd>/<MM>/<yyyy>", " " + dateNow[0] + "/" + dateNow[1] + "/" + dateNow[2]); } else { MessageBox.Show("File not Found!"); } //Save as myWordDoc.SaveAs2(ref SaveAs, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); myWordDoc.Close(); wordApp.Quit(); MessageBox.Show("File chứng nhận hợp quy của thiết bị được tạo"); } catch (Exception) { myWordDoc.Close(); wordApp.Quit(); MessageBox.Show("File chứng nhận hợp quy của thiết bị không được tạo thành công"); } }
// tạo chứng chỉ phần mềm public static void Create_Sofware_Certificate_Template(object filename, object SaveAs, string idContract, string pOnumber, string KHMS, string idNTKT, float numoD) { WordOffice.Application wordApp = new WordOffice.Application(); object missing = Missing.Value; WordOffice.Document myWordDoc = null; try { if (File.Exists((string)filename)) { object readOnly = false; object isVisible = false; wordApp.Visible = false; myWordDoc = wordApp.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); myWordDoc.Activate(); NTKT nTKT = new NTKT(); int ret = nTKT.GetObjectNTKT(idNTKT, ref nTKT); //find and replace FindAndReplace(wordApp, "<Contract_ID>", " " + idContract + " "); FindAndReplace(wordApp, "<PO_Number>", " " + pOnumber + " "); FindAndReplace(wordApp, "<KHMS>", " " + KHMS + " "); FindAndReplace(wordApp, "<NoD>", " " + (numoD).ToString() + " "); FindAndReplace(wordApp, "<NoD0.98>", " " + (numoD - Math.Round((numoD) * 0.02)).ToString() + " "); FindAndReplace(wordApp, "<NoD0.02>", " " + Math.Round((numoD) * 0.02).ToString() + " "); string[] dateNow = convertDateFormat.ConvertFormatDate(DateTime.Now.ToString("dd-MM-yyyy"), "dd-MM-yyyy", "dd/MM/yyyy"); FindAndReplace(wordApp, "<DateNow>", " " + dateNow[0] + "/" + dateNow[1] + "/" + dateNow[2]); } else { MessageBox.Show("File not Found!"); } //Save as myWordDoc.SaveAs2(ref SaveAs, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); myWordDoc.Close(); wordApp.Quit(); MessageBox.Show("File Giấy chứng nhận bản quyền phần mềm Được Tạo"); } catch (Exception) { myWordDoc.Close(); wordApp.Quit(); MessageBox.Show("File Giấy chứng nhận bản quyền phần mềm không Tạo thành công"); } }
//@Dưỡng Bùi -- Show thông tin NTKT lên UI public void setValueItemForNTKT(string IDNTKT) { NTKT nTKT = new NTKT(); nTKT.GetObjectNTKT(IDNTKT, ref nTKT); string idPO = null, poNumber = null, idContract = null; int ret = nTKT.getPOinfor(IDNTKT, ref idPO, ref poNumber, ref idContract); PO pO = new PO(); string namecontract = null, KHMS = null; pO.DisplayPO(idPO, ref namecontract, ref KHMS); this.txbKHMS.Text = (string)KHMS; this.txbIDContract.Text = (string)idContract; this.txbPOID.Text = (string)nTKT.POID; this.txbPONumber.Text = (string)poNumber; this.txbNTKTID.Text = (string)nTKT.ID_NTKT; dateTimePickerNTKT.Value = Convert.ToDateTime(nTKT.DateDuKienNTKT); }