private void btnIsReceived_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id <= 0) { return; } DialogResult result = MessageBox.Show("Bạn có chắc muốn xác nhận đã nhận hợp đồng này từ bộ phận vật tư?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } SupplierContractModel model = (SupplierContractModel)SupplierContractBO.Instance.FindByPK(id); model.IsReceived = true; SupplierContractBO.Instance.Update(model); _rowIndex = grvData.FocusedRowHandle; loadContract(); }
public void saveDocument() { newSupplierContractModel.DocumentID = dgvDocumentInformation.Rows[0].Cells[1].Value.ToString(); newSupplierContractModel.DocumentOwner = dgvDocumentInformation.Rows[1].Cells[1].Value.ToString(); newSupplierContractModel.IssueDate = dgvDocumentInformation.Rows[2].Cells[1].Value.ToString(); newSupplierContractModel.LastSavedDate = dgvDocumentInformation.Rows[3].Cells[1].Value.ToString(); newSupplierContractModel.FileName = dgvDocumentInformation.Rows[4].Cells[1].Value.ToString(); List <SupplierContractModel.DocumentHistory> documentHistories = new List <SupplierContractModel.DocumentHistory>(); int versionRowsCount = dgvDocumentHistory.Rows.Count; newSupplierContractModel.DocumentHistories = new List <SupplierContractModel.DocumentHistory>(); for (int i = 0; i < versionRowsCount - 1; i++) { var version = dgvDocumentHistory.Rows[i].Cells[0].Value?.ToString() ?? ""; var issueDate = dgvDocumentHistory.Rows[i].Cells[1].Value?.ToString() ?? ""; var changes = dgvDocumentHistory.Rows[i].Cells[2].Value?.ToString() ?? ""; newSupplierContractModel.DocumentHistories .Add(new SupplierContractModel.DocumentHistory(version, issueDate, changes)); } int approvalRowsCount = dgvDocumentApprovals.Rows.Count; newSupplierContractModel.DocumentApprovals = new List <SupplierContractModel.DocumentApproval>(); for (int i = 0; i < approvalRowsCount - 1; i++) { var role = dgvDocumentApprovals.Rows[i].Cells[0].Value?.ToString() ?? ""; var name = dgvDocumentApprovals.Rows[i].Cells[1].Value?.ToString() ?? ""; var signature = dgvDocumentApprovals.Rows[i].Cells[2].Value?.ToString() ?? ""; var date = dgvDocumentApprovals.Rows[i].Cells[3].Value?.ToString() ?? ""; newSupplierContractModel.DocumentApprovals .Add(new SupplierContractModel.DocumentApproval(role, name, signature, date)); } newSupplierContractModel.Purpose = purpose.Text; newSupplierContractModel.Recipients = recipients.Text; int definitionsRowsCount = dgvDefinitions.Rows.Count; newSupplierContractModel.Definitions = new List <SupplierContractModel.Definition>(); for (int i = 0; i < definitionsRowsCount - 1; i++) { var term = dgvDefinitions.Rows[i].Cells[0].Value?.ToString() ?? ""; var definition = dgvDefinitions.Rows[i].Cells[1].Value?.ToString() ?? ""; newSupplierContractModel.Definitions .Add(new SupplierContractModel.Definition(term, definition)); } int procurementItemsCount = dgvProcurementItems.Rows.Count; newSupplierContractModel.ProcurementItems = new List <SupplierContractModel.ProcurementItem>(); for (int i = 0; i < procurementItemsCount - 1; i++) { var itemName = dgvProcurementItems.Rows[i].Cells[0].Value?.ToString() ?? ""; var itemDescription = dgvProcurementItems.Rows[i].Cells[1].Value?.ToString() ?? ""; var itemQuantity = dgvProcurementItems.Rows[i].Cells[2].Value?.ToString() ?? ""; var itemPrice = dgvProcurementItems.Rows[i].Cells[3].Value?.ToString() ?? ""; newSupplierContractModel.ProcurementItems .Add(new SupplierContractModel.ProcurementItem(itemName, itemDescription, itemQuantity, itemPrice)); } newSupplierContractModel.Project = project.Text; newSupplierContractModel.Supplier = supplier.Text; int reviewCriteriaCount = dgvReviewCriteriaIntro.Rows.Count; newSupplierContractModel.ReviewCriterion = new List <SupplierContractModel.ReviewCriteria>(); for (int i = 0; i < reviewCriteriaCount - 1; i++) { var criteria = dgvReviewCriteriaIntro.Rows[i].Cells[0].Value?.ToString() ?? ""; var description = dgvReviewCriteriaIntro.Rows[i].Cells[1].Value?.ToString() ?? ""; newSupplierContractModel.ReviewCriterion .Add(new SupplierContractModel.ReviewCriteria(criteria, description)); } newSupplierContractModel.ReviewProcess = reviewProcess.Text; newSupplierContractModel.Payment = payment.Text; newSupplierContractModel.Invoicing = invoicing.Text; newSupplierContractModel.Confidentiality = confidentiality.Text; newSupplierContractModel.Termination = termination.Text; newSupplierContractModel.Disputes = disputes.Text; newSupplierContractModel.Indemnity = indemnity.Text; newSupplierContractModel.Law = law.Text; newSupplierContractModel.Agreement = agreement.Text; List <VersionControl <SupplierContractModel> .DocumentModel> documentModels = versionControl.DocumentModels; if (!versionControl.isEqual(currentSupplierContractModel, newSupplierContractModel)) { VersionControl <SupplierContractModel> .DocumentModel documentModel = new VersionControl <SupplierContractModel> .DocumentModel(newSupplierContractModel, DateTime.Now, VersionControl <SupplierContractModel> .generateID()); documentModels.Add(documentModel); string json = JsonConvert.SerializeObject(versionControl); currentSupplierContractModel = JsonConvert.DeserializeObject <SupplierContractModel>(JsonConvert.SerializeObject(newSupplierContractModel)); JsonHelper.saveDocument(json, Settings.Default.ProjectID, "SupplierContract"); MessageBox.Show("Suplier Contract saved successfully", "save", MessageBoxButtons.OK); } else { MessageBox.Show("No changes was made!", "save", MessageBoxButtons.OK); } }
void save() { if (IsNew) { MessageBox.Show("Bạn không thể tạo mới nhà cung cấp!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } #region NCC if (IsNew) { Supplier = new SuppliersModel(); } Supplier.Address = txtAddress.Text; Supplier.Agency = txtAgency.Text; Supplier.BangDanhGia = chkBangDanhGia.Checked; Supplier.BankAcount = txtBankAccount.Text; Supplier.BankAcountName = txtBankAccountName.Text; Supplier.BankName = txtBankName.Text; Supplier.ContactPerson = txtContactPerson.Text; Supplier.ContactPhone = txtContactPhone.Text; Supplier.Discount = TextUtils.ToDecimal(txtDiscount.Text); Supplier.DKKD = chkDKKD.Checked; Supplier.Email = txtEmail.Text; Supplier.HopDongNguyenTac = chkHopDongNguyenTac.Checked; Supplier.MaterialGroup = cboMaterialGroup.SelectedIndex; Supplier.MST = txtMST.Text; //Supplier.NhanTinStatus = 0; Supplier.Note = txtNote.Text; Supplier.Office = txtOffice.Text; Supplier.PaymentTerm = txtPaymentTerm.Text; Supplier.Phone = txtPhone.Text; Supplier.ProductProvided = txtProductProvided.Text; Supplier.StatusDisable = cboStatus.SelectedIndex; Supplier.SupplierCode = txtCode.Text; //Supplier.SupplierERPId = _supplierId; //Supplier.SupplierId = _supplierId; Supplier.SupplierName = txtName.Text; //Supplier.UserId = TextUtils.ToString(cboUser.EditValue); Supplier.UyQuyenHang = chkUyQuyenHang.Checked; Supplier.UpdatedDate = DateTime.Now; if (IsNew) { Supplier.DateArising = DateTime.Now; pt.InsertQLSX(Supplier); } else { pt.UpdateQLSX(Supplier); } #endregion #region Nguoi phu trach foreach (DataGridViewRow row in grvUser.Rows) { int id = TextUtils.ToInt(row.Cells["colULinkId"].Value); SuppliersUserLinkModel linkModel = new SuppliersUserLinkModel(); if (id > 0) { linkModel = (SuppliersUserLinkModel)SuppliersUserLinkBO.Instance.FindByPK(id); } linkModel.SupplierId = Supplier.SupplierId; linkModel.UserId = TextUtils.ToString(row.Cells["colUId"].Value); if (id > 0) { pt.Update(linkModel); } else { pt.Insert(linkModel); } } #endregion #region Hang cung cap foreach (DataGridViewRow row in grvHang.Rows) { int id = TextUtils.ToInt(row.Cells["colHLinkID"].Value); SuppliersManufacturerLinkModel linkModel = new SuppliersManufacturerLinkModel(); if (id > 0) { linkModel = (SuppliersManufacturerLinkModel)SuppliersManufacturerLinkBO.Instance.FindByPK(id); } linkModel.SupplierId = Supplier.SupplierId; linkModel.ManufacturerId = TextUtils.ToString(row.Cells["colHid"].Value); if (id > 0) { pt.Update(linkModel); } else { pt.Insert(linkModel); } } #endregion #region Hợp đồng foreach (DataGridViewRow row in grvContract.Rows) { int id = TextUtils.ToInt(row.Cells["colContractID"].Value); SupplierContractModel model = new SupplierContractModel(); if (id > 0) { model = (SupplierContractModel)SupplierContractBO.Instance.FindByPK(id); } model.SupplierId = Supplier.SupplierId; model.ContractType = TextUtils.ToInt(row.Cells["colContractType"].Value); model.SignDate = TextUtils.ToDate2(row.Cells["colSignDate"].Value); model.OutDate = TextUtils.ToDate2(row.Cells["colOutDate"].Value); if (id > 0) { pt.Update(model); } else { pt.Insert(model); } } #endregion #region Nhóm vật tư foreach (DataGridViewRow row in grvMaterialGroup.Rows) { int id = TextUtils.ToInt(row.Cells["colGroupLinkID"].Value); SupplierMaterialGroupLinkModel model = new SupplierMaterialGroupLinkModel(); if (id > 0) { model = (SupplierMaterialGroupLinkModel)SupplierMaterialGroupLinkBO.Instance.FindByPK(id); } model.SupplierId = Supplier.SupplierId; model.MaterialGroupID = TextUtils.ToInt(row.Cells["colMaterialGroupID"].Value); if (id > 0) { pt.Update(model); } else { pt.Insert(model); } } #endregion pt.CommitTransaction(); IsNew = false; _isSaved = true; loadHangGrid(); loadUserGrid(); loadContractGrid(); loadMaterialGroupGrid(); MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
private void loadDocument() { string json = JsonHelper.loadDocument(Settings.Default.ProjectID, "SupplierContract"); List <string[]> documentInfo = new List <string[]>(); newSupplierContractModel = new SupplierContractModel(); currentSupplierContractModel = new SupplierContractModel(); if (json != "") { versionControl = JsonConvert.DeserializeObject <VersionControl <SupplierContractModel> >(json); newSupplierContractModel = JsonConvert.DeserializeObject <SupplierContractModel>(versionControl.getLatest(versionControl.DocumentModels)); currentSupplierContractModel = JsonConvert.DeserializeObject <SupplierContractModel>(versionControl.getLatest(versionControl.DocumentModels)); documentInfo.Add(new string[] { "Document ID", currentSupplierContractModel.DocumentID }); documentInfo.Add(new string[] { "Document Owner", currentSupplierContractModel.DocumentOwner }); documentInfo.Add(new string[] { "Issue Date", currentSupplierContractModel.IssueDate }); documentInfo.Add(new string[] { "Last Save Date", currentSupplierContractModel.LastSavedDate }); documentInfo.Add(new string[] { "File Name", currentSupplierContractModel.FileName }); foreach (var row in documentInfo) { dgvDocumentInformation.Rows.Add(row); } dgvDocumentInformation.AllowUserToAddRows = false; foreach (var row in currentSupplierContractModel.DocumentHistories) { dgvDocumentHistory.Rows.Add(new string[] { row.Version, row.IssueDate, row.Changes }); } foreach (var row in currentSupplierContractModel.DocumentApprovals) { dgvDocumentApprovals.Rows.Add(new string[] { row.Role, row.Name, "", row.DateApproved }); } purpose.Text = currentSupplierContractModel.Purpose; recipients.Text = currentSupplierContractModel.Recipients; foreach (var row in currentSupplierContractModel.Definitions) { dgvDefinitions.Rows.Add(new string[] { row.Term, row.definition }); } foreach (var row in currentSupplierContractModel.ProcurementItems) { dgvProcurementItems.Rows.Add(new string[] { row.ItemName, row.ItemDescription, row.ItemQuantity, row.ItemPrice }); } supplier.Text = newSupplierContractModel.Supplier; project.Text = newSupplierContractModel.Project; foreach (var row in currentSupplierContractModel.ReviewCriterion) { dgvReviewCriteriaIntro.Rows.Add(new string[] { row.Criteria, row.Description }); } reviewProcess.Text = currentSupplierContractModel.ReviewProcess; payment.Text = currentSupplierContractModel.Payment; termination.Text = currentSupplierContractModel.Termination; law.Text = currentSupplierContractModel.Law; invoicing.Text = currentSupplierContractModel.Invoicing; disputes.Text = currentSupplierContractModel.Disputes; agreement.Text = currentSupplierContractModel.Agreement; confidentiality.Text = currentSupplierContractModel.Confidentiality; indemnity.Text = currentSupplierContractModel.Indemnity; } else { versionControl = new VersionControl <SupplierContractModel>(); versionControl.DocumentModels = new List <VersionControl <SupplierContractModel> .DocumentModel>(); documentInfo.Add(new string[] { "Document ID", "" }); documentInfo.Add(new string[] { "Document Owner", "" }); documentInfo.Add(new string[] { "Issue Date", "" }); documentInfo.Add(new string[] { "Last Save Date", "" }); documentInfo.Add(new string[] { "File Name", "" }); foreach (var row in documentInfo) { dgvDocumentInformation.Rows.Add(row); } dgvDocumentInformation.AllowUserToAddRows = false; } }
protected SupplierContractFacade(SupplierContractModel model) : base(model) { }