public void Deve_Criar_Um_Novo_Cliente() { var code = 1; var firstName = "Victor"; var lastName = "Domingues"; var name = new NameVo(firstName, lastName); var number = "11992535010"; var phone = new PhoneVo(number); var phone2 = new PhoneVo(number); var cpf = "3333333333"; var document = new DocumentVo(cpf, EDocumentType.Cpf); var emailAddress = "*****@*****.**"; var email = new EmailVo(emailAddress); var address = new Address(Tenant.Id, "", "", "", "", "", "", "", ""); var customer = new Customer(Tenant.Id, code, name, phone, phone2, email, document, address.Id, null); Assert.IsTrue(customer.Valid); Assert.AreEqual(customer.TenantId, Tenant.Id); Assert.AreEqual(customer.Name, name); Assert.AreEqual(customer.Phone, phone); Assert.AreEqual(customer.Phone2, phone2); Assert.AreEqual(customer.Email, email); Assert.AreEqual(customer.Document, document); Assert.AreEqual(customer.Code, code); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <DocumentVo> voList = new ValueObjectList <DocumentVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"SELECT document_name from t_document order by document_name"); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { DocumentVo outVo = new DocumentVo { DocumentName = dataReader["document_name"].ToString() }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); sql.Append(@"insert into t_document(doc_name, doc_no, doc_type, model, version, update_date, department) values(:doc_name, :doc_no, :doc_type, :model, :version, :update_date, :department)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameter("doc_id", inVo.DocumentID); sqlParameter.AddParameter("doc_name", inVo.DocumentName); sqlParameter.AddParameter("doc_no", inVo.DocumentNo); sqlParameter.AddParameter("doc_type", inVo.DocumentType); sqlParameter.AddParameter("model", inVo.ModelCode); sqlParameter.AddParameter("version", inVo.Version); sqlParameter.AddParameter("update_date", inVo.Update_Date); sqlParameter.AddParameter("department", inVo.Department); //execute SQL DocumentVo outVo = new DocumentVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void btnDelete_Click(object sender, EventArgs e) { string docName = dgvDocument.CurrentRow.Cells["doc_name"].Value.ToString(); string docType = dgvDocument.CurrentRow.Cells["doc_type"].Value.ToString(); string parentPath = @"Z:\(01)KK03\QA\(00)Public\DOCUMENT\" + docType + @"\"; string id = dgvDocument.CurrentRow.Cells["doc_id"].Value.ToString(); DialogResult result = MessageBox.Show("Do you really want to delete this document ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { DialogResult result1 = MessageBox.Show("This action will delete the document file! Please click 'NO' if you don't want to delete it!", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result1 == DialogResult.Yes) { try { DocumentVo docvo = (DocumentVo)DefaultCbmInvoker.Invoke(new DeleteDocumentCmb(), new DocumentVo { DocumentID = int.Parse(id) }); File.Delete(parentPath + docName); MessageBox.Show("This document is deleted!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); initForm(); } catch (Framework.ApplicationException ex) { logger.Error(ex.GetMessageData()); popUpMessage.ApplicationError(ex.GetMessageData(), Text); return; } } } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <DocumentVo> voList = new ValueObjectList <DocumentVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"SELECT distinct groups from t_document where department = :department order by groups"); sqlParameter.AddParameterString("department", inVo.Department); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { DocumentVo outVo = new DocumentVo { Group = dataReader["groups"].ToString(), }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); DocumentVo voList = new DocumentVo(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("delete from document_mgr where doc_id = '" + inVo.DocumentID + "'"); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); DataSet ds = new DataSet(); ds = sqlCommandAdapter.ExecuteDataSet(sqlParameter); //execute SQL //IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); DocumentVo outVo = new DocumentVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public ICommandResult Handle(AddCustomerCommand command) { // Verificar se o CPF já existe if (_customerRepository.checkDocumentExists(command.documentNumber)) { AddNotification("Document", "Este CPF já está em uso!"); return(null); } // Verificar se o email já existe if (_customerRepository.checkEmailExists(command.emailAddress)) { AddNotification("Email", "Este email já está em uso!"); return(null); } // Gerar o novo cliente var document = new DocumentVo(command.documentNumber); var email = new EmailVo(command.emailAddress); var address = new AddressVo( command.addressStreet, command.addressNumber, command.addressNeighborhood, command.addressCity, command.addressState, command.addressZipCode ); var customer = new CustomerEntity( command.name, command.birthDate, document, address, email, DateTime.Now); // Adicionar as notificação AddNotifications(document.Notifications); AddNotifications(email.Notifications); AddNotifications(address.Notifications); AddNotifications(customer.Notifications); if (this.Invalid) { return(null); } // Inserir no banco _customerRepository.save(customer); // Enviar E-mail de boas vindas /*_emailService.Send( * customer.Name.ToString(), * customer.Email.Address, * string.Format(EmailTemplates.WelcomeEmailTitle, customer.Name), * string.Format(EmailTemplates.WelcomeEmailBody, customer.Name));*/ return(new AddCustomerCommandResult(customer.id.ToString())); }
private void depart_cmb_SelectedIndexChanged(object sender, EventArgs e) { if (depart_cmb.SelectedItem != null) { ModelVo mdvo = (ModelVo)model_cmb.SelectedItem; DocumentVo dcvo = (DocumentVo)depart_cmb.SelectedItem; ValueObjectList <DocumentVo> dvolist = null; try { dvolist = (ValueObjectList <DocumentVo>)DefaultCbmInvoker.Invoke(grCbm, new DocumentVo { Department = depart_cmb.Text }); } catch (Framework.ApplicationException ex) { logger.Error(ex.GetMessageData()); popUpMessage.ApplicationError(ex.GetMessageData(), Text); return; } group_cmb.DisplayMember = "Group"; group_cmb.DataSource = dvolist.GetList(); group_cmb.Text = ""; ValueObjectList <DocumentVo> dlist = null; try { dlist = (ValueObjectList <DocumentVo>)DefaultCbmInvoker.Invoke(getndcbm, new DocumentVo { ModelID = mdvo.ModelId, Department = depart_cmb.Text }); } catch (Framework.ApplicationException ex) { logger.Error(ex.GetMessageData()); popUpMessage.ApplicationError(ex.GetMessageData(), Text); return; } doc_name_cmb.DisplayMember = "DocumentName"; doc_name_cmb.DataSource = dlist.GetList(); doc_name_cmb.Text = ""; try { dvolist = (ValueObjectList <DocumentVo>)DefaultCbmInvoker.Invoke(dmoCbm, new DocumentVo { ModelID = mdvo.ModelId, Department = depart_cmb.Text }); } catch (Framework.ApplicationException ex) { logger.Error(ex.GetMessageData()); popUpMessage.ApplicationError(ex.GetMessageData(), Text); return; } doc_type_cmb.DisplayMember = "DocumentType"; doc_type_cmb.DataSource = dvolist.GetList(); doc_type_cmb.Text = ""; } }
public Customer(Guid tenantId, int code, NameVo name, PhoneVo phone, PhoneVo phone2, EmailVo email, DocumentVo document, Guid addressId, string ie) { SetTenantId(tenantId); Code = code; Name = name; Phone = phone; Phone2 = phone2; Email = email; Document = document; AddressId = addressId; Ie = ie; }
public Company(Guid tenantId, string name, DocumentVo document, PhoneVo phone, EmailVo emailVo, Address address, Guid addressId, string site) { SetTenantId(tenantId); Name = name; Document = document; Phone = phone; Email = emailVo; Address = address; AddressId = addressId; Site = site; }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <DocumentVo> voList = new ValueObjectList <DocumentVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"SELECT document_name from t_document where 1 = 1"); //sqlParameter.AddParameterString("department", inVo.Department); if (!String.IsNullOrEmpty(inVo.Department)) { sql.Append(" and department =:department "); sqlParameter.AddParameterString("department", inVo.Department); } if (!String.IsNullOrEmpty(inVo.Group)) { sql.Append(" and groups =:groups "); sqlParameter.AddParameterString("groups", inVo.Group); } if (!String.IsNullOrEmpty(inVo.DocumentCode)) { sql.Append(" and document_cd =:document_cd "); sqlParameter.AddParameterString("document_cd", inVo.DocumentCode); } sql.Append(" and model_id =:model_id "); sqlParameter.AddParameterInteger("model_id", inVo.ModelID); sql.Append(" order by document_name"); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { DocumentVo outVo = new DocumentVo { DocumentName = dataReader["document_name"].ToString(), }; voList.add(outVo); } dataReader.Close(); return(voList); }
private void btnUpdate_Click(object sender, EventArgs e) { if (dgvDocument.SelectedCells.Count > 0) { DocumentVo selectedvo = (DocumentVo)dgvDocument.CurrentRow.DataBoundItem; if (new AddDocumentForm { vo = selectedvo }.ShowDialog() != DialogResult.OK) { initForm(); } } }
private void update_btn_Click(object sender, EventArgs e) { if (document_dgv.SelectedCells.Count > 0) { DocumentVo uvo = (DocumentVo)document_dgv.CurrentRow.DataBoundItem; if (new AddDocumentForm { vo = uvo }.ShowDialog() != DialogResult.OK) { selectdata(); } } }
public ICommandResult Handle(EditCustomerCommand command) { var oldCustomer = _customerRepository.getById(command.id); // Verificar se existe o cliente if (oldCustomer == null) { AddNotification("Customer", "Cliente não encontrado"); return(null); } // Gerar o novo cliente var document = new DocumentVo(command.documentNumber); var email = new EmailVo(command.emailAddress); var address = new AddressVo( command.addressStreet, command.addressNumber, command.addressNeighborhood, command.addressCity, command.addressState, command.addressZipCode ); var customer = new CustomerEntity( command.name, command.birthDate, document, address, email, oldCustomer.createAt, id: oldCustomer.id); // Adicionar as notificação AddNotifications(document.Notifications); AddNotifications(email.Notifications); AddNotifications(address.Notifications); AddNotifications(customer.Notifications); if (this.Invalid) { return(null); } // altera _customerRepository.update(customer); return(new AddCustomerCommandResult(customer.id.ToString())); }
public CustomerEntity( string name, DateTime?birthDate, DocumentVo document, AddressVo address, EmailVo email, DateTime createAt, Guid?id = null) : base(id: id, createAt: createAt) { this.name = name; this.birthDate = birthDate; this.document = document; this.address = address; this.email = email; AddNotifications(new Contract() .IsNotNullOrEmpty(name, "CustomerEntity.name", "Nome é obrigatório") ); }
private void version_cmb_TextChanged(object sender, EventArgs e) { ModelVo mdvo = (ModelVo)model_cmb.SelectedItem; DocumentVo dvo = (DocumentVo)version_cmb.SelectedItem; ValueObjectList <DocumentVo> dvolist = null; try { dvolist = (ValueObjectList <DocumentVo>)DefaultCbmInvoker.Invoke(getndcbm, new DocumentVo { ModelID = mdvo.ModelId, DocumentCode = version_cmb.Text }); } catch (Framework.ApplicationException ex) { logger.Error(ex.GetMessageData()); popUpMessage.ApplicationError(ex.GetMessageData(), Text); return; } doc_name_cmb.DisplayMember = "DocumentName"; doc_name_cmb.DataSource = dvolist.GetList(); doc_name_cmb.Text = ""; }
private void doc_type_cmb_SelectedIndexChanged(object sender, EventArgs e) { ModelVo mdvo = (ModelVo)model_cmb.SelectedItem; DocumentVo dcvo = (DocumentVo)doc_type_cmb.SelectedItem; ValueObjectList <DocumentVo> dovolist = null; try { dovolist = (ValueObjectList <DocumentVo>)DefaultCbmInvoker.Invoke(dcdCbm, new DocumentVo { ModelID = mdvo.ModelId, DocumentType = dcvo.DocumentType }); } catch (Framework.ApplicationException ex) { logger.Error(ex.GetMessageData()); popUpMessage.ApplicationError(ex.GetMessageData(), Text); return; } version_cmb.DisplayMember = "DocumentCode"; version_cmb.DataSource = dovolist.GetList(); version_cmb.Text = ""; }
protected DomainBaseUnitTest() { Settings.SecurityKey = "cbffeba849124af8b7b89675c223fd3d"; Tenant = new AppTenant("Treeze", "localhost:43500", null, null); User = new User(new NameVo("Victor", "Luiz"), new EmailVo("*****@*****.**"), UserRole.User, new PasswordVo("12345678", "12345678"), null, Tenant.Id); var code = 1; var firstName = "Victor"; var lastName = "Domingues"; var name = new NameVo(firstName, lastName); var number = "11992535010"; var phone = new PhoneVo(number); var phone2 = new PhoneVo(number); var cpf = "3333333333"; var document = new DocumentVo(cpf, EDocumentType.Cpf); var emailAddress = "*****@*****.**"; var email = new EmailVo(emailAddress); var address = new Address(Tenant.Id, "", "", "", "", "", "", "", ""); Customer = new Customer(Tenant.Id, code, name, phone, phone2, email, document, address.Id, null); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); sql.Append(@"update t_document set document_cd=:document_cd, model_id=:model_id, department=:department, groups=:groups, document_type=:document_type, update_date_time=now(), revision=:revision"); sql.Append(" where document_id =:document_id"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameter("document_id", inVo.DocumentID); sqlParameter.AddParameter("document_cd", inVo.DocumentCode); sqlParameter.AddParameter("model_id", inVo.ModelID); sqlParameter.AddParameter("department", inVo.Department); sqlParameter.AddParameter("groups", inVo.Group); sqlParameter.AddParameter("document_type", inVo.DocumentType); sqlParameter.AddParameter("update_date_time", inVo.TimeFrom); sqlParameter.AddParameter("revision", inVo.Revision); //execute SQL DocumentVo outVo = new DocumentVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); sql.Append(@"insert into t_document(document_cd, document_name, document_type, model_id, department, groups, revision, update_date_time, registration_user_cd, registration_date_time, factory_cd)"); sql.Append(@"values(:document_cd, :document_name, :document_type, :model_id, :department, :groups, :revision, now(), :registration_user_cd, now(), :factory_cd)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameter("document_id", inVo.DocumentID); sqlParameter.AddParameter("document_cd", inVo.DocumentCode); sqlParameter.AddParameter("document_name", inVo.DocumentName); sqlParameter.AddParameter("document_type", inVo.DocumentType); sqlParameter.AddParameter("model_id", inVo.ModelID); sqlParameter.AddParameter("department", inVo.Department); sqlParameter.AddParameter("groups", inVo.Group); sqlParameter.AddParameter("revision", inVo.Revision); sqlParameter.AddParameter("update_date_time", inVo.TimeFrom); sqlParameter.AddParameter("registration_user_cd", inVo.RegistrationUserCode); sqlParameter.AddParameter("registration_date_time", inVo.RegistrationDateTime); sqlParameter.AddParameter("factory_cd", inVo.FactoryCode); //execute SQL DocumentVo outVo = new DocumentVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void OK_btn_Click(object sender, EventArgs e) { string mcPath = @"Z:\(01)KK03\QA\(00)Public\DOCUMENT\"; string parentPath; string User = UserData.GetUserData().UserCode; if (User == "225" || User == "558" || User == "1927") { parentPath = mcPath + @"01. AREA A\"; } else { parentPath = mcPath + @"02. AREA B\"; } string gr = group_txt.Text; //string mdl = model_cmb.Text; string folder1 = parentPath + gr + @"\SOP\"; string folder2 = parentPath + gr + @"\Standard\"; string folder3 = parentPath + gr + @"\Data\"; string folder4 = parentPath + gr + @"\Form\"; string folder5 = parentPath + gr + @"\Drawing\"; string folder6 = parentPath + gr + @"\Report\"; string folder7 = parentPath + gr + @"\Inspect\"; string folder8 = parentPath + gr + @"\Traceability\"; if (!checkdata()) { return; } DocumentVo outVo = new DocumentVo(); DocumentVo inVo = new DocumentVo { DocumentID = this.vo.DocumentID, TimeFrom = this.updatetime_dtp.Value, ModelID = ((ModelVo)this.model_cmb.SelectedItem).ModelId, DocumentCode = doc_code_txt.Text, DocumentName = doc_name_txt.Text, DocumentType = DocType_txt.Text, Group = group_txt.Text, Department = depart_txt.Text, Revision = revision_txt.Text, RegistrationUserCode = UserData.GetUserData().UserCode, FactoryCode = UserData.GetUserData().FactoryCode }; try { if (inVo.DocumentID > 0) { outVo = (DocumentVo)DefaultCbmInvoker.Invoke(new UpdateDocumentCbm(), inVo); } else { outVo = (DocumentVo)DefaultCbmInvoker.Invoke(new AddDocumentCbm(), inVo); } } catch (Com.Nidec.Mes.Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if (outVo.AffectedCount > 0) { this.DialogResult = DialogResult.OK; } #region Create a new target folder. string[] dcd = doc_code_txt.Text.Split('-'); Process prc = new Process(); if (dcd[2] == "SOP") { try { if (!Directory.Exists(folder1)) { Directory.CreateDirectory(folder1); File.Move(linksave_txt.Text, folder1 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder1 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder1; prc.Start(); } } catch (Exception) { e.ToString(); } } if (dcd[2] == "STD") { try { if (!System.IO.Directory.Exists(folder2)) { System.IO.Directory.CreateDirectory(folder2); File.Move(linksave_txt.Text, folder2 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder2 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder2; prc.Start(); } } catch { } } if (dcd[2] == "DTA") { try { if (!System.IO.Directory.Exists(folder3)) { System.IO.Directory.CreateDirectory(folder3); File.Move(linksave_txt.Text, folder3 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder3 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder3; prc.Start(); } } catch { } } if (dcd[2] == "FRM") { try { if (!System.IO.Directory.Exists(folder4)) { System.IO.Directory.CreateDirectory(folder4); File.Move(linksave_txt.Text, folder4 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder4 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder4; prc.Start(); } } catch { } } if (dcd[2] == "DRW") { try { if (!System.IO.Directory.Exists(folder5)) { System.IO.Directory.CreateDirectory(folder5); File.Move(linksave_txt.Text, folder5 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder5 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder5; prc.Start(); } } catch { } } if (dcd[2] == "RPT") { try { if (!System.IO.Directory.Exists(folder6)) { System.IO.Directory.CreateDirectory(folder6); File.Move(linksave_txt.Text, folder6 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder6 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder6; prc.Start(); } } catch { } } if (dcd[2] == "INS") { try { if (!System.IO.Directory.Exists(folder7)) { System.IO.Directory.CreateDirectory(folder7); File.Move(linksave_txt.Text, folder7 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder7 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder7; prc.Start(); } } catch { } } if (dcd[2] == "TRC") { try { if (!System.IO.Directory.Exists(folder8)) { System.IO.Directory.CreateDirectory(folder8); File.Move(linksave_txt.Text, folder8 + doc_name_txt.Text); MessageBox.Show("Document folder is created", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { File.Move(linksave_txt.Text, folder8 + doc_name_txt.Text); MessageBox.Show("Document folder is already exists!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (DialogResult == DialogResult.OK) { prc.StartInfo.FileName = folder8; prc.Start(); } } catch { } } #endregion }
private void OK_btn_Click(object sender, EventArgs e) { string mcPath = @"Z:\(01)KK03\QA\(00)Public\DOCUMENT\"; string parentPath = mcPath + cmbDocType.Text + @"\" + txtDocName.Text; if (!checkdata()) { return; } //Add or Update DocumentVo outVo = new DocumentVo(); DocumentVo inVo = new DocumentVo { DocumentID = vo.DocumentID, Update_Date = DateTime.Now, ModelCode = txtModel.Text, DocumentNo = txtDocNo.Text, DocumentName = txtDocName.Text, DocumentType = cmbDocType.Text, Department = cmbDepartment.Text, Version = txtVersion.Text, }; try { //Update Document if (inVo.DocumentID > 0) { outVo = (DocumentVo)DefaultCbmInvoker.Invoke(new UpdateDocumentCbm(), inVo); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002); popUpMessage.Information(messageData, "Infomation"); } } //Add Document else { //Create folder and move file if (!Directory.Exists(mcPath + cmbDocType.Text)) { Directory.CreateDirectory(mcPath + cmbDocType.Text); File.Move(linksave_txt.Text, parentPath); } else { File.Move(linksave_txt.Text, parentPath); } outVo = (DocumentVo)DefaultCbmInvoker.Invoke(new AddDocumentCbm(), inVo); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001); popUpMessage.Information(messageData, "Infomation"); } //Refresh Form Common.ResetControlValues.ResetControlValue(this); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <DocumentVo> voList = new ValueObjectList <DocumentVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"SELECT a.document_id, a.document_cd, a.document_name, b.model_cd,a.department, a.groups, a.revision, a.update_date_time, a.registration_user_cd,a.registration_date_time, a.registration_user_cd, a.factory_cd from t_document a left join m_model b on b.model_id = a.model_id WHERE 1 = 1"); //sql.Append(@"time_record >= :timefrom"); //sqlParameter.AddParameterDateTime("timefrom", inVo.TimeFrom); //sql.Append(" and time_record <= :timeto"); //sqlParameter.AddParameterDateTime("timeto", inVo.TimeTo); sql.Append(" and model_cd =:model_cd "); sqlParameter.AddParameterString("model_cd", inVo.ModelCode); if (!String.IsNullOrEmpty(inVo.DocumentCode)) { sql.Append(" and document_cd =:document_cd "); sqlParameter.AddParameterString("document_cd", inVo.DocumentCode); } if (!String.IsNullOrEmpty(inVo.DocumentName)) { sql.Append(" and document_name =:document_name "); sqlParameter.AddParameterString("document_name", inVo.DocumentName); } if (!String.IsNullOrEmpty(inVo.Department)) { sql.Append(" and department =:department "); sqlParameter.AddParameterString("department", inVo.Department); } if (!String.IsNullOrEmpty(inVo.Group)) { sql.Append(" and groups =:groups "); sqlParameter.AddParameterString("groups", inVo.Group); } if (!String.IsNullOrEmpty(inVo.DocumentType)) { sql.Append(" and document_type =:document_type "); sqlParameter.AddParameterString("document_type", inVo.DocumentType); } if (!String.IsNullOrEmpty(inVo.RegistrationUserCode)) { sql.Append(" and registration_user_cd =:registration_user_cd "); sqlParameter.AddParameterString("registration_user_cd", inVo.RegistrationUserCode); } sql.Append(" order by document_cd "); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { DocumentVo outVo = new DocumentVo { // , h., i., k., o.prodution_work_content_name DocumentID = int.Parse(dataReader["document_id"].ToString()), DocumentCode = dataReader["document_cd"].ToString(), DocumentName = dataReader["document_name"].ToString(), Department = dataReader["department"].ToString(), Group = dataReader["groups"].ToString(), TimeFrom = DateTime.Parse(dataReader["update_date_time"].ToString()), RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()), ModelCode = dataReader["model_cd"].ToString(), Revision = dataReader["revision"].ToString(), }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { DocumentVo inVo = (DocumentVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <DocumentVo> voList = new ValueObjectList <DocumentVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("select doc_id, doc_name, doc_no, version, update_date, doc_type, model, department from t_document where 1 = 1"); if (!String.IsNullOrEmpty(inVo.ModelCode)) { sql.Append(" and model = '" + inVo.ModelCode + "'"); } if (!String.IsNullOrEmpty(inVo.DocumentName)) { sql.Append(" and doc_name like '%" + inVo.DocumentName + "%'"); } if (!String.IsNullOrEmpty(inVo.DocumentNo)) { sql.Append(" and doc_no like '%" + inVo.DocumentNo + "%'"); } if (!String.IsNullOrEmpty(inVo.DocumentType)) { sql.Append(" and doc_type = '" + inVo.DocumentType + "'"); } if (!String.IsNullOrEmpty(inVo.Department)) { sql.Append(" and department = '" + inVo.Department + "'"); } sql.Append(" order by doc_id"); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { DocumentVo outVo = new DocumentVo { DocumentID = int.Parse(dataReader["doc_id"].ToString()), DocumentName = dataReader["doc_name"].ToString(), DocumentNo = dataReader["doc_no"].ToString(), Version = dataReader["version"].ToString(), Update_Date = DateTime.Parse(dataReader["update_date"].ToString()), DocumentType = dataReader["doc_type"].ToString(), ModelCode = dataReader["model"].ToString(), Department = dataReader["department"].ToString() }; voList.add(outVo); } dataReader.Close(); return(voList); //DataSet ds = new DataSet(); //ds = sqlCommandAdapter.ExecuteDataSet(sqlParameter); //DocumentVo outVo = new DocumentVo //{ // dt = ds.Tables[0] //}; //return outVo; }