private void btnSave_Click(object sender, EventArgs e) { m_SubCate.TypePartCode = txtCode.Text; m_SubCate.TypePartName = txtName.Text; m_SubCate.Note = txtNote.Text; try { int Id = 0; using (IUnitOfWork uow = new UnitOfWork()) { uow.TypePartBaseRepository.Update(m_SubCate); uow.Commit(); } TreeTagPart treeTag = new TreeTagPart(); treeTag.NodeTye = TreeTagPart.Types.TypePart; treeTag.GroupPartIDTag = m_SubCate.GroupPartId != null ? (int)m_SubCate.GroupPartId:0; treeTag.TypePartIDTag = Id; TreeNode node = new TreeNode(m_SubCate.TypePartName); node.Text = m_SubCate.TypePartName; node.Name = m_SubCate.TypePartName; if (UpdateNode != null) { UpdateNode(node); } lblNotify1.SetText(UI.updatesuccess, ToolBoxCS.LabelNotify.EnumStatus.Success); Close(); } catch { lblNotify1.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed); } }
private void AddNodeToTree(TreeNode newNode) { TreeNode parentNode = treeView1.SelectedNode; TreeTagPart parentTag = parentNode.Tag as TreeTagPart; TreeTagPart newnodeTag = newNode.Tag as TreeTagPart; if (parentNode == null) { parentNode = treeView1.TopNode; } treeView1.BeginUpdate(); if (parentTag.NodeTye == newnodeTag.NodeTye) { parentNode = parentNode.Parent; if (parentNode == null) { treeView1.Nodes.Add(newNode); } else { parentNode.Nodes.Add(newNode); } } else { parentNode.Nodes.Add(newNode); } treeView1.EndUpdate(); treeView1.Refresh(); }
private void tsDeleteSubCate_Click(object sender, EventArgs e) { DialogResult result = FormUtility.MsgDelete(); if (result == DialogResult.Yes) { TreeTagPart treeTag = treeView1.SelectedNode.Tag as TreeTagPart; if (treeTag != null) { try { using (IUnitOfWork uow = new UnitOfWork()) { uow.TypePartBaseRepository.Remove(treeTag.TypePartIDTag); uow.Commit(); } treeView1.Nodes.Remove(treeView1.SelectedNode); } catch { lblNotify1.SetText(UI.removefailed, LabelNotify.EnumStatus.Failed); } } } }
private void viewSupplierToolStripMenuItem1_Click(object sender, EventArgs e) { TreeTagPart treeTag = treeView1.SelectedNode.Tag as TreeTagPart; if (treeTag == null) { return; } InformationSearch parameterSerach = new InformationSearch { GroupPartID = treeTag.GroupPartIDTag, TypePartID = treeTag.TypePartIDTag, SeriesPartID = treeTag.SeriesPartIDTag, PartID = treeTag.PartIDTag }; FrmViewSupplier frmViewSupplier = FrmViewSupplier.Instance(); frmViewSupplier.LoadInformationSearch(parameterSerach); if (AddTab != null) { AddTab(frmViewSupplier); } }
private void tsCreateSubCate2_Click(object sender, EventArgs e) { TreeTagPart treetag = treeView1.SelectedNode.Tag as TreeTagPart; frmcreateTypePart frmCreate = new frmcreateTypePart(treetag.GroupPartIDTag, treeView1.SelectedNode.Parent.Text); frmCreate.AddNode = AddNodeToTree; frmCreate.Show(); }
void DisplayInformation(TreeNode nodeInformation) { TreeTagPart treetag = nodeInformation.Tag as TreeTagPart; if (treetag == null) { return; } if (treetag.NodeTye != TreeTagPart.Types.Part) { return; } Part selectPart; Model.Sourcing selectSouring; txtPricePart.ReadOnly = true; txtNamePart.ReadOnly = true; txtDescription.ReadOnly = true; cboSupplier.Enabled = false; using (IUnitOfWork uow = new UnitOfWork()) { selectPart = uow.PartBaseRepository.Find(treetag.PartIDTag); selectSouring = uow.SourcingBaseRepository.FindPartByIDPart(treetag.PartIDTag); uow.Commit(); } if (selectPart == null) { return; } if (selectSouring == null) { return; } txtNamePart.Text = selectPart.PartName; txtPricePart.Text = (selectPart.Pricespart) > 0 ? selectPart.Pricespart.ToString() : "0"; txtDescription.Text = selectPart.Description; cboSupplier.SelectedValue = selectSouring.SupplierID; currentSelecSupplier = selectSouring.SupplierID; txtNamePart.Focus(); txtNumberPart.Text = selectPart.PartNumber; txtDescription.ReadOnly = true; lbTitle.Text = "Information detail sourcing"; PictureUtility.BindImage(PictureImage, selectPart.ImagePath); if (selectPart.ImagePath != null) { currentImagePath = selectPart.ImagePath; } txtNumberPart.ReadOnly = true; treeView1.Select(); }
private void tsCreateSerie2_Click(object sender, EventArgs e) { TreeTagPart treetag = treeView1.SelectedNode.Tag as TreeTagPart; frmCreateSeriesPart frmCreate = new frmCreateSeriesPart(treetag.GroupPartIDTag, treetag.TypePartIDTag, treeView1.SelectedNode.Parent.Text); Enabled = false; frmCreate.AddNode = AddNodeToTree; frmCreate.ShowDialog(); Enabled = true; }
void SaveSourcing(Part partInsert) { try { Model.Sourcing sourcing = new Model.Sourcing(); sourcing.SupplierID = (cboSupplier.SelectedItem as TmTech_v1.Model.Supplier).SupplierId; sourcing.Note = txtDescription.Text; sourcing.CreateDate = DateTime.Now; sourcing.CreateBy = UserManagement.UserSession.FullName; partInsert.CreateBy = UserManagement.UserSession.FullName; partInsert.CreateDate = DateTime.Now; partInsert.PartName = txtNamePart.Text; partInsert.Pricespart = decimal.Parse(txtPricePart.Text); partInsert.PartNumber = txtNumberPart.Text; partInsert.Description = txtDescription.Text; using (UnitOfWork uow = new UnitOfWork()) { int idPart = uow.PartBaseRepository.AddandGetRequestPaymentId(partInsert); sourcing.PartID = idPart; int idSouriing = uow.SourcingBaseRepository.AddandGetRequestPaymentId(sourcing); uow.Commit(); TreeTagPart treeTag = new TreeTagPart(); treeTag.NodeTye = TreeTagPart.Types.Part; treeTag.SeriesPartIDTag = isCreateNew.SeriesPartID; treeTag.PartIDTag = idPart; treeTag.PartNumber = txtNumberPart.Text; treeTag.GroupPartIDTag = mainCreate.GroupPartIDTag; treeTag.TypePartIDTag = mainCreate.TypePartIDTag; TreeNode node = new TreeNode(txtNamePart.Text); node.Tag = treeTag; AddNodeToTree(node); txtNumberPart.ReadOnly = true; } lblNotify1.SetText(UI.createsuccess, LabelNotify.EnumStatus.Success); DisplayInformation(treeView1.SelectedNode); isInsert = false; txtDescription.ReadOnly = true; FormUtility.ReadOnlySpecial(pnlContent); cboSupplier.Enabled = false; } catch (Exception) { lblNotify1.SetText(UI.createfailed, LabelNotify.EnumStatus.Failed); } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { TreeTagPart treetag = treeView1.SelectedNode.Tag as TreeTagPart; Part selectPart; Model.Sourcing selectSouring; using (IUnitOfWork uow = new UnitOfWork()) { selectPart = uow.PartBaseRepository.Find(treetag.PartIDTag); selectSouring = uow.SourcingBaseRepository.FindPartByIDPart(treetag.PartIDTag); uow.Commit(); } if (selectPart == null) { return; } if (selectSouring == null) { return; } txtNumberPart.Text = selectPart.PartNumber; txtNamePart.Text = selectPart.PartName; txtPricePart.Text = (selectPart.Pricespart) > 0 ? selectPart.Pricespart.ToString() : "0"; txtDescription.Text = selectPart.Description; cboSupplier.SelectedItem = selectPart.SeriesPartID; lbTitle.Text = "update sourcing"; isUpdatePart = selectPart; isSourcing = selectSouring; isInsert = false; isUpdate = true; objBackUp = new PartBackUp(); objBackUp.PartName = txtNamePart.Text; objBackUp.Description = txtDescription.Text; objBackUp.PartName = txtNumberPart.Text; objBackUp.Pricespart = txtPricePart.Text != string.Empty ? decimal.Parse(txtPricePart.Text) : 0; objBackUp.ImagePath = currentImagePath; PictureUtility.BindImage(PictureImage, selectPart.ImagePath); txtNumberPart.ReadOnly = true; txtPricePart.ReadOnly = false; txtNamePart.ReadOnly = false; txtDescription.ReadOnly = false; cboSupplier.Enabled = true; mainUpdate = treetag; txtDescription.ReadOnly = false; }
private void toolStripMenuItem5_Click(object sender, EventArgs e) { TreeTagPart treetag = treeView1.SelectedNode.Tag as TreeTagPart; if (treetag != null) { isCreateNew.SeriesPartID = treetag.SeriesPartIDTag; } txtNamePart.Text = string.Empty; txtDescription.Text = string.Empty; txtPricePart.Text = string.Empty; PictureImage.InitialImage = null; FormUtility.ResetForm(pnlContent); ComboboxUtility.BindSupplier(cboSupplier); }
private void btnSave_Click_1(object sender, EventArgs e) { if (ValidationUtility.FieldNotAllowNull(this) == false) { return; } m_GroupPart.GroupPartName = txtName.Text; m_GroupPart.GroupPartCode = txtCode.Text; m_GroupPart.Note = txtNote.Text; m_GroupPart.ModifyDate = DateTime.Now; m_GroupPart.ModifyBy = UserManagement.UserSession.UserName; try { using (IUnitOfWork uow = new UnitOfWork()) { if (uow.GroupPartBaseRepository.FindExist(m_GroupPart) == true) { lblNotify1.SetText(UI.codehasexist, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } else { uow.GroupPartBaseRepository.Update(m_GroupPart); TreeNode node = new TreeNode(m_GroupPart.GroupPartName); node.Name = m_GroupPart.GroupPartName; node.Text = m_GroupPart.GroupPartName; TreeTagPart tag = new TreeTagPart(); tag.NodeTye = TreeTagPart.Types.GroupPart; tag.GroupPartIDTag = m_GroupPart.GroupPartId; node.Tag = tag; if (UpdateNode != null) { UpdateNode(node); } lblNotify1.SetText(UI.updatesuccess, ToolBoxCS.LabelNotify.EnumStatus.Success); Close(); } uow.Commit(); } return; } catch { lblNotify1.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } }
private void btnSave_Click_1(object sender, EventArgs e) { if (ValidationUtility.FieldNotAllowNull(this) == false) { return; } Model.GroupPart cate = new Model.GroupPart(); cate.GroupPartName = txtName.Text; cate.GroupPartCode = txtCode.Text; cate.Note = txtNote.Text; cate.CreateBy = UserManagement.UserSession.UserName; cate.CreateDate = DateTime.Now; cate.ModifyDate = DateTime.Now; cate.ModifyBy = UserManagement.UserSession.UserName; try { int Id = 0; using (IUnitOfWork uow = new UnitOfWork()) { Id = uow.GroupPartBaseRepository.AddandGetRequestPaymentId(cate); uow.Commit(); } TreeTagPart treeTag = new TreeTagPart(); treeTag.NodeTye = TreeTagPart.Types.GroupPart; treeTag.GroupPartIDTag = Id; TreeNode node = new TreeNode(cate.GroupPartName); node.Tag = treeTag; if (AddNode != null) { AddNode(node); } lblNotify1.SetText(UI.createsuccess, ToolBoxCS.LabelNotify.EnumStatus.Success); Close(); } catch { lblNotify1.SetText(UI.createfailed, ToolBoxCS.LabelNotify.EnumStatus.Failed); } }
private void tsEditSub_Click(object sender, EventArgs e) { TreeTagPart treetag = treeView1.SelectedNode.Tag as TreeTagPart; TypePart sub; using (IUnitOfWork uow = new UnitOfWork()) { sub = uow.TypePartBaseRepository.Find(treetag.TypePartIDTag); uow.Commit(); } if (sub == null) { return; } frmEditTypePart frmEdit = new frmEditTypePart(sub, treeView1.SelectedNode.Parent.Text); Enabled = false; frmEdit.UpdateNode = updateNode; frmEdit.ShowDialog(); Enabled = true; }
private void tsEditCate_Click(object sender, EventArgs e) { TreeTagPart treetag = treeView1.SelectedNode.Tag as TreeTagPart; GroupPart cate; using (IUnitOfWork uow = new UnitOfWork()) { cate = uow.GroupPartBaseRepository.Find(treetag.GroupPartIDTag); uow.Commit(); } if (cate == null) { return; } frmEditGroupPart frmEdit = new frmEditGroupPart(cate); Enabled = false; frmEdit.UpdateNode = updateNode; frmEdit.Show(); Enabled = true; }
private void btnSave_Click(object sender, EventArgs e) { if (m_Sub == null) { lblNotify1.SetText(UI.hasnoinfomation, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } SeriesPart serie = new SeriesPart(); serie.TypePartId = m_Sub.TypePartID; serie.SeriesPartCode = txtCode.Text; serie.SeriesPartName = txtName.Text; serie.Note = txtNote.Text; try { int Id = 0; using (IUnitOfWork uow = new UnitOfWork()) { Id = uow.SeriesPartBaseRepository.AddandGetRequestPaymentId(serie); uow.Commit(); } TreeTagPart treeTag = new TreeTagPart(); treeTag.NodeTye = TreeTagPart.Types.SeriesPart; treeTag.TypePartIDTag = m_Sub.TypePartID; treeTag.GroupPartIDTag = m_Sub.GroupPartId.Value; treeTag.SeriesPartIDTag = Id; TreeNode node = new TreeNode(serie.SeriesPartName); node.Tag = treeTag; if (AddNode != null) { AddNode(node); } lblNotify1.SetText(UI.createsuccess, ToolBoxCS.LabelNotify.EnumStatus.Success); Close(); } catch { lblNotify1.SetText(UI.createfailed, ToolBoxCS.LabelNotify.EnumStatus.Failed); } }
private void createSourcingToolStripMenuItem_Click(object sender, EventArgs e) { TreeTagPart treetag = treeView1.SelectedNode.Tag as TreeTagPart; mainCreate = treetag; if (treetag != null) { isCreateNew.SeriesPartID = treetag.SeriesPartIDTag; } txtNamePart.Tag = txtNamePart.Text; objBackUp = new PartBackUp(); objBackUp.PartName = txtNamePart.Text; objBackUp.Description = txtDescription.Text; objBackUp.PartName = txtNumberPart.Text; objBackUp.Pricespart = txtPricePart.Text != string.Empty ? decimal.Parse(txtPricePart.Text) : 0; objBackUp.ImagePath = PictureImage.Tag != null?PictureImage.Tag.ToString() : null; objBackUp.ImagePath = currentImagePath; PictureUtility.BindImage(PictureImage, "@32121"); txtNamePart.Text = string.Empty; txtDescription.Text = string.Empty; txtNumberPart.Text = string.Empty; txtPricePart.Text = string.Empty; PictureImage.InitialImage = null; ComboboxUtility.BindSupplier(cboSupplier); lbTitle.Text = "Create new sourcing"; isInsert = true; isUpdate = false; txtPricePart.ReadOnly = false; txtNamePart.ReadOnly = false; txtDescription.ReadOnly = false; cboSupplier.Enabled = true; txtNumberPart.ReadOnly = false; }
private void treeView1_MouseClick(object sender, MouseEventArgs e) { TreeViewHitTestInfo info = treeView1.HitTest(treeView1.PointToClient(Cursor.Position)); TreeNode node = info.Node; TreeTagPart treeTag = node.Tag as TreeTagPart; treeView1.SelectedNode = node; if (node != null) { if (e.Button == MouseButtons.Left) { if (treeTag == null) { return; } } if (e.Button == MouseButtons.Right) { if (treeTag.GroupPartIDTag > 0 && treeTag.TypePartIDTag == 0 && treeTag.SeriesPartIDTag == 0) { ctxGroupPart.Show(Cursor.Position); } if (treeTag.GroupPartIDTag > 0 && treeTag.TypePartIDTag > 0 && treeTag.SeriesPartIDTag == 0) { ctxTypePart.Show(Cursor.Position); } if (treeTag.GroupPartIDTag > 0 && treeTag.TypePartIDTag > 0 && treeTag.SeriesPartIDTag > 0) { ctxSeriePart.Show(Cursor.Position); } if (treeTag.GroupPartIDTag > 0 && treeTag.TypePartIDTag > 0 && treeTag.SeriesPartIDTag > 0 && treeTag.PartIDTag > 0) { ctxPart.Show(Cursor.Position); } } } }
private new void Update() { if (ValidationUtility.FieldNotAllowNull(this) == false) { return; } if (isUpdatePart.SeriesPartID < 0) { lblNotify1.SetText("thiếu thông tin về series ID", LabelNotify.EnumStatus.Failed); return; } if (txtPricePart.Text == string.Empty) { lblNotify1.SetText("Chưa nhập giá", LabelNotify.EnumStatus.Failed); txtPricePart.Focus(); return; } try { decimal.Parse(txtPricePart.Text); } catch (Exception) { lblNotify1.SetText("Chưa nhập giá hoặc giá không chính x", LabelNotify.EnumStatus.Failed); txtPricePart.Focus(); return; } if (cboSupplier.SelectedValue == null) { lblNotify1.SetText("Chưa nhập thông tin nhà cung cấp", LabelNotify.EnumStatus.Failed); } if (PictureImage.Tag != null) { isUpdatePart.ImagePath = PictureUtility.SaveImg(PictureImage.Tag.ToString()); } isSourcing.SupplierID = (cboSupplier.SelectedItem as TmTech_v1.Model.Supplier).SupplierId; isSourcing.ModifyBy = UserManagement.UserSession.UserName; isSourcing.ModifyDate = DateTime.Now; isUpdatePart.ModifyBy = UserManagement.UserSession.UserName; isUpdatePart.ModifyDate = DateTime.Now; isUpdatePart.Pricespart = decimal.Parse(txtPricePart.Text); isUpdatePart.PartName = txtNamePart.Text; isUpdatePart.Description = txtDescription.Text; isSourcing.Note = txtDescription.Text; try { using (UnitOfWork uow = new UnitOfWork()) { uow.PartBaseRepository.Update(isUpdatePart); uow.SourcingBaseRepository.Update(isSourcing); uow.Commit(); TreeTagPart treeTag = new TreeTagPart(); treeTag.NodeTye = TreeTagPart.Types.Part; treeTag.SeriesPartIDTag = isUpdatePart.SeriesPartID; treeTag.PartIDTag = isUpdatePart.PartID; treeTag.GroupPartIDTag = mainUpdate.GroupPartIDTag; treeTag.TypePartIDTag = mainUpdate.TypePartIDTag; TreeNode node = new TreeNode(txtNamePart.Text); node.Name = txtNamePart.Text; node.Tag = treeTag; updateNode(node); } lblNotify1.SetText(UI.updatesuccess, LabelNotify.EnumStatus.Success); DisplayInformation(treeView1.SelectedNode); txtDescription.ReadOnly = true; isUpdate = false; FormUtility.ReadOnlySpecial(pnlContent); cboSupplier.Enabled = false; } catch (Exception) { lblNotify1.SetText(UI.updatefailed, LabelNotify.EnumStatus.Failed); } }