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 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 bootstrapButton2_Click(object sender, EventArgs e) { if (isInsert == false && isUpdate == false) { if (objBackUp != null) { txtNamePart.Text = objBackUp.PartName; txtDescription.Text = objBackUp.Description; txtNumberPart.Text = objBackUp.PartName; txtPricePart.Text = objBackUp.Pricespart > 0 ? objBackUp.Pricespart.ToString() : string.Empty; PictureImage.Image = objBackUp.ImageBackUp; PictureUtility.BindImage(PictureImage, objBackUp.ImagePath); cboSupplier.SelectedValue = currentSelecSupplier; currentSelecSupplier = -1; objBackUp = null; } txtNamePart.ReadOnly = txtDescription.ReadOnly = txtNumberPart.ReadOnly = txtPricePart.ReadOnly = true; treeView1.Select(); return; } DialogResult result = FormUtility.MscWarming(); if (result == DialogResult.Yes) { if (objBackUp != null) { txtNamePart.Text = objBackUp.PartName; txtDescription.Text = objBackUp.Description; txtNumberPart.Text = objBackUp.PartName; txtPricePart.Text = objBackUp.Pricespart > 0 ? objBackUp.Pricespart.ToString() : string.Empty; PictureUtility.BindImage(PictureImage, objBackUp.ImagePath); cboSupplier.SelectedValue = currentSelecSupplier; currentSelecSupplier = -1; objBackUp = null; } txtNamePart.ReadOnly = txtDescription.ReadOnly = txtNumberPart.ReadOnly = txtPricePart.ReadOnly = true; if (isInsert == true || isUpdate == true) { TreeNode nodeSelect = treeView1.SelectedNode; DisplayInformation(nodeSelect); isInsert = false; isUpdate = false; } else { TreeNode nodeSelect = treeView1.SelectedNode; DisplayInformation(nodeSelect); } } else { return; } }