Example #1
0
        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);
            }
        }
Example #2
0
        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;
        }