private void btnSendDespatch_Click(object sender, EventArgs e) { try { bool valid = true; //aynı kısıye gıdecek faturalar secılı mı kontrolu string receiverVkn = tableGrid.SelectedRows[0].Cells[nameof(EI.Despatch.receiverVkn)].Value.ToString(); foreach (DataGridViewRow row in tableGrid.SelectedRows) { if (row.Cells[nameof(EI.Despatch.receiverVkn)].Value != null && row.Cells[nameof(EI.Despatch.receiverVkn)].Value.ToString() != receiverVkn) //vkn farklı ıse { MessageBox.Show(Lang.selectOnePerson); //sadece aynı kısıye olan faturaları bırlıkte gonderebılırsınız valid = false; break; } } if (valid) //uymayan irsaliye durumu yoksa { //db den getırılen serı Namelerı comboboxda sectır FrmDialogSelectItem frmDialogSelectSeriName = new FrmDialogSelectItem(true, ""); if (frmDialogSelectSeriName.ShowDialog() == DialogResult.OK) { FrmDialogSelectItem frmDialogIdSelectAlias = new FrmDialogSelectItem(false, receiverVkn); ////gb sectır if (frmDialogIdSelectAlias.ShowDialog() == DialogResult.OK) { IdArrContentArrModel ıdContentModel = createInvListWithNewId(frmDialogSelectSeriName.selectedValue); //send despatch string errorMessage = Singl.despatchControllerGet.sendDespatch(frmDialogIdSelectAlias.selectedValue, receiverVkn); if (errorMessage != null) { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { for (int cnt = 0; cnt < tableGrid.SelectedRows.Count; cnt++) { string uuidRow = tableGrid.SelectedRows[cnt].Cells[nameof(EI.Despatch.uuid)].Value.ToString(); string oldFolderPath = Singl.DespatchAdviceDalGet.getDespatch(uuidRow, nameof(EI.Direction.DRAFT)).folderPath; //yenı folderpath olustur string newFolderPath = FolderControl.createDespatchDocPath(ıdContentModel.newIdArr[cnt], nameof(EI.Direction.OUT), nameof(EI.DocumentType.XML)); // yenı path db ye yazılır //db de yenı id,direction,folderpath,statenote guncellenır if (Singl.DespatchAdviceDalGet.updateDespatchIdDirectionFolderPathStateNote(uuidRow, nameof(EI.Direction.DRAFT), ıdContentModel.newIdArr[cnt], nameof(EI.Direction.OUT), newFolderPath, nameof(EI.StatusType.SEND)) == 1) { //eskı folderPathdekı dosyayı konumdan sıler FolderControl.deleteFileFromPath(oldFolderPath); //yenı folderpath ile yenı id eklenmıs xmli diske kaydet FolderControl.writeFileOnDiskWithString(ıdContentModel.newXmlContentArr[cnt], newFolderPath); } else { MessageBox.Show("Güncel bilgileri Db ye kaydetme işlemi basarısız,İşlemi tekrar gerceklestırınız" + tableGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.ID)].Value.ToString()); return; } } //db ye, en son olusturulan yenı ınv id serisinin son itemi ıle serı no ve yıl guncelle Singl.invIdSerilazeDalGet.updateLastAddedInvIdSeri(ıdContentModel.newIdArr.Last()); //datagrıd listesini guncelle gridUpdateDespatchList(Singl.DespatchAdviceDalGet.getDespatchList(despactDirection)); MessageBox.Show(Lang.succesful);//"basarılı" } } frmDialogIdSelectAlias.Dispose(); } frmDialogSelectSeriName.Dispose(); } } catch (FaultException <REQUEST_ERRORType> ex) { if (ex.Detail.ERROR_CODE == 2005) { Singl.authControllerGet.Login(FrmLogin.usurname, FrmLogin.password); } MessageBox.Show(Lang.operationFailed + ex.Detail.ERROR_SHORT_DES, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error); //işlem basarısız } catch (System.Data.Entity.Infrastructure.DbUpdateException) { MessageBox.Show(Lang.dbFault, "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnSendDraftArchive_Click(object sender, EventArgs e) { try { //db den getırılen serı Namelerı comboboxda sectır FrmDialogSelectItem frmDialogSelectSeriName = new FrmDialogSelectItem(true, ""); if (frmDialogSelectSeriName.ShowDialog() == DialogResult.OK) { ArchiveContentPropertiesModel[] archiveModelArr = new ArchiveContentPropertiesModel[tableArchiveGrid.SelectedRows.Count]; string seriName = frmDialogSelectSeriName.selectedValue; string[] newIdArr = InvoiceIdSetSerilaze.createNewInvId(seriName, tableArchiveGrid.SelectedRows.Count); for (int cnt = 0; cnt < tableArchiveGrid.SelectedRows.Count; cnt++) { ArchiveContentPropertiesModel archiveContentPropertiesModel = new ArchiveContentPropertiesModel(); archiveContentPropertiesModel.uuid = tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.uuid)].Value.ToString(); archiveContentPropertiesModel.archiveType = tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.eArchiveType)].Value.ToString(); //alınan contenttın ıdsını degıstırerek koy string content = Singl.archiveControllerGet.getArchiveContentXml(archiveContentPropertiesModel.uuid); archiveContentPropertiesModel.content = XmlControl.xmlInvoiceChangeIdValue(content, newIdArr[cnt]); if (tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.receiverMail)].Value != null) //mail gonderılmek ısstenıyorsa { archiveContentPropertiesModel.mail = tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.receiverMail)].Value.ToString(); } Singl.archiveControllerGet.addContentPropertiesToList(archiveContentPropertiesModel); archiveModelArr[cnt] = archiveContentPropertiesModel; } string responseErrorMessage = Singl.archiveControllerGet.sendEarchive(); if (responseErrorMessage != null) { MessageBox.Show(responseErrorMessage, Lang.operationFailed, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //db de fatura durumunu taslaktan cıkar for (int cnt = 0; cnt < archiveModelArr.Length; cnt++) { string oldFolderPath = Singl.archiveInvoiceDalGet.findArchive(archiveModelArr[cnt].uuid).folderPath; //path degıstır string newFolderPath = FolderControl.inboxFolderArchive + newIdArr[cnt] + "." + nameof(EI.DocumentType.XML); //guncelleme basarılıysa if (Singl.archiveInvoiceDalGet.updateArchiveIdStateNoteDraftFlagFolderPath(archiveModelArr[cnt].uuid, newIdArr[cnt], EI.StateNote.SEND.ToString(), false, newFolderPath) == 1) { //diskten xmli sil FolderControl.deleteFileFromPath(oldFolderPath); //yenı kontentı dıske kaydet FolderControl.writeFileOnDiskWithString(archiveModelArr[cnt].content, newFolderPath); } else { MessageBox.Show("Db ye kaydetme işlemi basarısız,İşlemi tekrar gerceklestırınız" + tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.ID)].Value.ToString()); return; } } //db ye, en son olusturulan yenı ınv id serisinin son itemi ıle serı no ve yıl guncelle Singl.invIdSerilazeDalGet.updateLastAddedInvIdSeri(newIdArr.Last()); MessageBox.Show(Lang.succesful);//"Başarılı" gridArchiveUpdateList(Singl.archiveInvoiceDalGet.getArchiveList(true)); } } } catch (FaultException <REQUEST_ERRORType> ex) { if (ex.Detail.ERROR_CODE == 2005) { Singl.authControllerGet.Login(FrmLogin.usurname, FrmLogin.password); } MessageBox.Show(ex.Detail.ERROR_SHORT_DES, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Data.Entity.Infrastructure.DbUpdateException ex) { MessageBox.Show(Lang.dbFault + " " + ex.InnerException.Message.ToString(), "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Data.DataException ex) { MessageBox.Show(ex.InnerException.Message.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void btnLoadDespatch_Click(object sender, EventArgs e) { try { //db den getırılen serı Namelerı comboboxda sectır FrmDialogSelectItem frmDialogIdSeriName = new FrmDialogSelectItem(true, ""); if (frmDialogIdSeriName.ShowDialog() == DialogResult.OK) { IdArrContentArrModel idArrContentArrModel = createInvListWithNewId(frmDialogIdSeriName.selectedValue); //load ınvda direction degıstırmıyoruz o yuzden false if (idArrContentArrModel != null) { string errorMessage = Singl.despatchControllerGet.loadDespatchToService(); if (errorMessage != null) // basarısızsa { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else //servıse yukleme ıslemı basarılıysa { for (int cnt = 0; cnt < tableGrid.SelectedRows.Count; cnt++) { string uuidRow = tableGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.uuid)].Value.ToString(); //yenı ıd ile yenı folderpath olustur string newFolderPath = FolderControl.createDespatchDocPath(idArrContentArrModel.newIdArr[cnt], nameof(EI.Direction.DRAFT), nameof(EI.DocumentType.XML)); string oldFolderPath = Singl.DespatchAdviceDalGet.getDespatch(uuidRow, nameof(EI.Direction.DRAFT)).folderPath; //db verileri guncelle if (Singl.DespatchAdviceDalGet.updateDespatchIdCdateStatusGibCodeStateNoteFolderPath(uuidRow, nameof(EI.Direction.DRAFT), idArrContentArrModel.newIdArr[cnt], DateTime.Now, nameof(EI.StatusType.LOAD) + " - " + nameof(EI.SubStatusType.SUCCEED), -1, nameof(EI.StatusType.LOAD), newFolderPath) == 1) { //yenı olust. folderpath ıle xml ı dıske kaydet FolderControl.writeFileOnDiskWithString(idArrContentArrModel.newXmlContentArr[cnt], newFolderPath); //eskı folderPathdekı dosyayı konumdan sıler FolderControl.deleteFileFromPath(oldFolderPath); } else { MessageBox.Show("Güncel bilgileri Db ye kaydetme işlemi basarısız,İşlemi tekrar gerceklestırınız" + tableGrid.SelectedRows[cnt].Cells[nameof(EI.Despatch.ID)].Value.ToString()); return; } } //db ye, en son olusturulan yenı ınv id serisinin son itemi ıle serı no ve yıl guncelle Singl.invIdSerilazeDalGet.updateLastAddedInvIdSeri(idArrContentArrModel.newIdArr.Last()); // db den cekılen taslak faturaları datagrıdde listele gridUpdateDespatchList(Singl.DespatchAdviceDalGet.getDespatchList(nameof(EI.Direction.DRAFT))); MessageBox.Show(Lang.successLoad);//"yukleme basarılı" } } frmDialogIdSeriName.Dispose(); } } catch (FaultException <REQUEST_ERRORType> ex) { if (ex.Detail.ERROR_CODE == 2005) { Singl.authControllerGet.Login(FrmLogin.usurname, FrmLogin.password); } MessageBox.Show(ex.Detail.ERROR_SHORT_DES, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Data.Entity.Infrastructure.DbUpdateException) { MessageBox.Show(Lang.dbFault, "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }