/* private void TextBox_Changed(object sender, EventArgs e) * { * if(tbxDurationContract.SelectionLength > 0) * { * dateTimePickerDurationDateContract.Value = dateTimePickerDateSignedPO.Value.AddDays(Convert.ToInt32(tbxDurationContract.Text)); * } * }*/ private void btnSave_Click(object sender, EventArgs e) { int ret = 0; /*Save The Edited Contract Info */ //ContractObj newContract = new ContractObj(); newContract.KHMS = txbKHMS.Text; newContract.IdContract = tbContract.Text; newContract.NameContract = tbBidName.Text; newContract.CodeAccounting = tbAccountingCode.Text; newContract.DateSigned = dateTimePickerDateSignedPO.Value.ToString("yyyy-MM-dd"); newContract.TypeContract = txbTypeContract.Text; newContract.DurationContract = tbxDurationContract.Text; dateTimePickerDurationDateContract.Value = dateTimePickerDateSignedPO.Value.AddDays(Convert.ToInt32(tbxDurationContract.Text)); newContract.ActiveDateContract = dateTimePickerActiveDateContract.Value.ToString("yyyy-MM-dd"); newContract.ValueContract = tbxValueContract.Text; newContract.DurationGuranteePO = tbxDurationPO.Text; newContract.SiteA = tbxSiteA.Text; newContract.SiteB = tbxSiteB.Text; newContract.ExperationDate = ExpirationDate.Value.ToString("yyyy-MM-dd"); ret = newContract.GetDetailContract(tbContract.Text); string DriveName = ""; if (0 == ret) { /*Create Folder Contract on F Disk*/ //string strContractDirectory = "F:\\OPM\\" + tbContract.Text; //strContractDirectory = strContractDirectory.Replace('/','_'); //strContractDirectory = strContractDirectory.Replace('-', '_'); //Tạo thư mục trong ổ đĩa D hoặc E DriveInfo[] driveInfos = DriveInfo.GetDrives(); foreach (DriveInfo driveInfo in driveInfos) { //MessageBox.Show(driveInfo.Name.ToString()); if (String.Compare(driveInfo.Name.ToString().Substring(0, 3), @"D:\") == 0 || String.Compare(driveInfo.Name.ToString().Substring(0, 3), @"E:\") == 0) { //MessageBox.Show(driveInfo.Name.ToString().Substring(0, 1)); DriveName = driveInfo.Name.ToString().Substring(0, 3); break; } } string strContractDirectory = DriveName + "OPM\\" + tbContract.Text; if (!Directory.Exists(strContractDirectory)) { //Directory.CreateDirectory(strContractDirectory); Directory.CreateDirectory(DriveName + "OPM"); Directory.CreateDirectory(DriveName + "OPM" + tbContract.Text); MessageBox.Show(strContractDirectory); MessageBox.Show("Folder Contract have been created!!!"); } else { MessageBox.Show("Folder already exist!!!"); } ret = newContract.InsertNewContract(newContract); if (0 == ret) { MessageBox.Show(ConstantVar.CreateNewContractFail); } else { UpdateCatalogPanel(tbContract.Text); /*Create Bao Lanh Thuc Hien Hop Dong*/ this.Cursor = Cursors.WaitCursor; Directory.CreateDirectory(DriveName + "LP"); string filename = DriveName + @"LP\MSTT_Template.docx"; //string filename = @"F:\LP\MSTT_Template.docx"; string strBLHPName = strContractDirectory + "\\Bao_Lanh_Hop_Dong.docx"; OpmWordHandler.CreateBLTH_Contract(filename, strBLHPName, tbContract.Text, tbBidName.Text, dateTimePickerDateSignedPO.Value.ToString(), tbxSiteB.Text, txbGaranteeValue.Text, txbGaranteeActiveDate.Text); /*Send Email To DF*/ OPMEmailHandler.fSendEmail("Mail From DoanTD Gmail", strBLHPName); this.Cursor = Cursors.Default; } } else { ret = newContract.UpdateExistedContract(newContract); if (0 == ret) { MessageBox.Show(ConstantVar.CreateNewContractFail); } else { MessageBox.Show("Update Success"); State(true); } } return; }
private void btnSave_Click(object sender, EventArgs e) { /*Check PO in DB*/ int ret = 0; /*Save The Edited Contract Info */ PO newPO = new PO(); newPO.IDContract = txbIDContract.Text; newPO.IDPO = txbPOCode.Text; newPO.PONumber = txbPOName.Text; newPO.NumberOfDevice = float.Parse(txbNumberDevice.Text); newPO.DateCreatedPO = TimePickerDateCreatedPO.Value.ToString("yyyy-MM-dd"); newPO.DurationConfirmPO = TimePickerDateConfirmPO.Value.ToString("yyyy-MM-dd"); newPO.DefaultActiveDatePO = TimepickerDefaultActive.Value.ToString("yyyy-MM-dd"); newPO.DeadLinePO = TimePickerDeadLinePO.Value.ToString("yyyy-MM-dd"); newPO.TotalValuePO = float.Parse(txbValuePO.Text); /*Create Folder Contract on F Disk*/ string strContractDirectory = txbIDContract.Text.Replace('/', '_'); strContractDirectory = strContractDirectory.Replace('-', '_'); string strPODirectory = "F:\\OPM\\" + strContractDirectory + "\\" + txbPOName.Text; ret = newPO.GetDetailPO(txbPOCode.Text); if (0 == ret) { if (!Directory.Exists(strPODirectory)) { Directory.CreateDirectory(strPODirectory); MessageBox.Show("Folder have been created!!!"); } else { MessageBox.Show("Folder already exist!!!"); } ret = newPO.InsertNewPO(newPO); if (0 == ret) { MessageBox.Show(ConstantVar.CreateNewPOFail); } else { MessageBox.Show(ConstantVar.CreateNewPOSuccess); UpdateCatalogPanel(txbPOName.Text); /*Create Bao Lanh Thuc Hien Hop Dong*/ string fileBLTUPO_temp = @"F:\LP\BLPO_Template.docx"; string strBLTUPOName = strPODirectory + "\\De nghi Bao lanh thuc hien & tam ung PO MSTT.docx"; /*truy Suất thông tin của Contract*/ ContractObj contractObj = new ContractObj(); ContractObj.GetObjectContract(txbIDContract.Text, ref contractObj); this.Cursor = Cursors.WaitCursor; OpmWordHandler.Create_BLTU_PO(fileBLTUPO_temp, strBLTUPOName, txbPOName.Text, txbIDContract.Text, contractObj.NameContract, contractObj.DateSigned, TimePickerDateCreatedPO.Value.ToString("yyyy-MM-dd"), txbValuePO.Text, txbTUPO.Text, contractObj.SiteB, txbActiveAfter.Text); /*Send Email To DF*/ OPMEmailHandler.fSendEmail("Mail From DoanTD Gmail", strBLTUPOName); this.Cursor = Cursors.Default; } /*Create Bao Lanh Thuc Hien Hop Dong*/ //string filename = @"F:\LP\MSTT_Template.docx"; //string strBLHPName = strContractDirectory + "\\Bao_Lanh_Hop_Dong.docx"; //OpmWordHandler.CreateBLTH_Contract(filename, strBLHPName, tbContract.Text, tbBidName.Text, tbxDateSigned.Text, tbxSiteB.Text, txbGaranteeValue.Text, txbGaranteeActiveDate.Text); /*Send Email To DF*/ //OPMEmailHandler.fSendEmail("Mail From DoanTD Gmail", strBLHPName); //UpdateCatalogPanel(txbPOCode.Text); } }