DividingPlanItem AssignValues()
        {
            try {
                 DividingPlanItem _item = new DividingPlanItem();
                 if (_item.DividingPlanHeaderID != 0)
                 {
                     _item.DividingPlanHeaderID = Convert.ToInt16(this.DividingPlanHeaderID);
                 }
                 else {
                     _item.DividingPlanHeaderID = _dividingPanID;
                 }
                 
                _item.DividingPlanItemID = this.DividingPlanID;
                _item.OprationNo = txtOprationNo.Text;
                _item.OprationName = txtoprationName.Text;
                _item.MachineType = cmbMachineType.Text;
                _item.SMVType = cmbSmvType.Text;
                _item.SMV =Convert.ToDouble( txtSMV.Text);
                _item.PartName = txtPartName.Text;
                _item.WorkstationNo =Convert.ToInt16( txtWno.Text);
                _item.OpNo =Convert.ToInt16( txtOpNo.Text);
             

                return _item;
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.Message);
                return null;
            }
        
        }
        void saveOparation() {
            try {

                GenaricRepository<DividingPlanHeader> _dHeaderRepo = new GenaricRepository<DividingPlanHeader>(new ItrackContext());
                DividingPlanHeader dHeader = new DividingPlanHeader();
                dHeader.LineNo = txtLineNo.Text;
                dHeader.ProductionPerHour =Convert.ToInt16( txtProductionPerHour.Text);
                dHeader.StyleID = txtStyleNo.Text;
                dHeader.TotalEmployee =Convert.ToInt16( txtTotalEmployee.Text);
                dHeader.Target =Convert.ToInt16(txtTarget.Text);

                _dHeaderRepo.Add(dHeader);

                dHeader.DividingPlanheaderID = _dHeaderRepo.GetAll().ToList().Last().DividingPlanheaderID;
                
                
                
                for (int i = 0; i < gridView3.RowCount; i++)
                {
                   
                    GenaricRepository<DividingPlanItem> _dItemRepo = new GenaricRepository<DividingPlanItem>(new ItrackContext());
                    
                    DividingPlanItem dItem = new DividingPlanItem();
                   
                    dItem.OprationNo = gridView3.GetRowCellValue(i, "OprationNo").ToString();
                    dItem.OprationName = gridView3.GetRowCellValue(i, "OprationName").ToString();
                    dItem.SMVType = gridView3.GetRowCellValue(i, "SMVType").ToString();
                    dItem.MachineType = gridView3.GetRowCellValue(i, "MachineType").ToString();
                    dItem.SMV =Convert.ToDouble( gridView3.GetRowCellValue(i, "SMV").ToString());
                    dItem.DividingPlanHeaderID = dHeader.DividingPlanheaderID;
                    dItem.PartName = gridView3.GetRowCellValue(i, "PartName").ToString();
                    
                    string status = gridView3.GetRowCellValue(i, "Selected").ToString();
                    GenaricRepository<DividingPlanTemp> _dItemTempRepo = new GenaricRepository<DividingPlanTemp>(new ItrackContext());
                    DividingPlanTemp dTemp = new DividingPlanTemp();
                    dTemp.DividingPlanTempID = Convert.ToInt16(gridView3.GetRowCellValue(i, "DividingPlanTempID").ToString());
                    if (status == "True")
                    {
                        _dItemRepo.Insert(dItem);
                        _dItemTempRepo.Delete(dTemp);
                    }
                    else { 
                        
                    }

                    
                }
            }
            catch(Exception ex){
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #3
0
        void getUpdatedList() {

            foreach (var item in lst.Where(x => x.Selected == true))
            {
                //lstselected.Add(new OperationListSelection(item.OprationNo, item.OprationName, item.SMV, item.WorkstationNo,item.Selected));
                MessageBox.Show(item.OprationNo);
                DividingPlanItem _item = new DividingPlanItem();
                if (_item.DividingPlanHeaderID != 0)
                {
                    _item.DividingPlanHeaderID = Convert.ToInt16(this.DividingPlanHeader);
                }
                else
                {
                    _item.DividingPlanHeaderID = DividingPlanHeader;
                }

                
                _item.OprationNo = item.OprationNo;
                _item.OprationName = item.OprationName;
                _item.MachineType = item.MachineType;
                _item.SMVType = item.SMVType;
                _item.SMV = item.SMV;
                _item.PartName = item.PartName;
                _item.OperationRole = item.OperationRole;
                _item.WorkstationNo = item.WorkstationNo;
                GenaricRepository<DividingPlanItem> _pDidingItemRepository = new GenaricRepository<DividingPlanItem>(new ItrackContext());

                _item.OpNo =    _pDidingItemRepository.GetAll().ToList().Where(X => X.DividingPlanHeaderID == _item.DividingPlanHeaderID).Count();

                if (_pDidingItemRepository.Insert(_item) == true) 
                {
                    
                }
                


            }
            MessageBox.Show("Save Sucessfully !", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            
        
        }