Пример #1
0
       TempOpration AssignTempOperation(TempOpration _TempOpration)
        {
            try
            {
        
                return _TempOpration;
            }
            catch (Exception ex)
            {

                Debug.WriteLine(ex.Message);
                return null;

            }
        }
Пример #2
0
        void SaveOpration() {
            try {
                
                foreach (var _opration in lstTempOpration) 
                {
                    GenaricRepository<OperationPool> _ORepository = new GenaricRepository<OperationPool>(new ItrackContext());
                    foreach (var item in _CompanyRepository.GetAll().Where(x => x.isDefaultCompany == true))
                    {
                        _Company.CompanyID = item.CompanyID;

                    }
                    _Operation.CompanyID = _Company.CompanyID;
                    _Operation.OperationPoolID = _opration.OprationID;
                    _Operation.OpationName = _opration.OparationName;
                    _Operation.SMV = _opration.SMV;
                    _Operation.SMVType = _opration.SMVType;
                    _Operation.MachineType = _opration.MachineType;
                    _Operation.Remark = _opration.Remark;
                    _Operation.OprationRole = _opration.OprationRole;
                    _Operation.OprationGrade = _opration.OprationGrade;
                    _Operation.PartName = _opration.PartName;

                    _ORepository.Insert(_Operation);

                    GenaricRepository<TempOpration> _tOpration = new GenaricRepository<TempOpration>(new ItrackContext());
                    TempOpration t = new TempOpration();
                    t.TempOprationID = _opration.TempOprationID;
                   _tOpration.Delete(t);
                  

                }
            }
            catch(Exception ex){
                Debug.WriteLine(ex.Message);
            }
        }
Пример #3
0
        public  BindingList<OperationPool> ReadMyExcel(DevExpress.XtraEditors.ProgressBarControl bar )
        {
            
            TempOpration t = new TempOpration();
            bar.Show();
            bar.Properties.Maximum = lastRow;
            bar.Properties.Step = 1;
            oprationList.Clear();
            // EmpList.Clear();
            for (int index = 5; index <= lastRow; index++)
            {
                System.Array MyValues = (System.Array)MySheet.get_Range("A" + index.ToString(), "G" + index.ToString()).Cells.Value;

                string opration = "";
                string _OprationName = "";
                string _MachineType = "None";
                string _SMVtype = "none";
                string _SMV = "";
                string _PartName = "None";
                string _OprationRole = "None";
                string _OprationGrade = "None";
                bool _hasData = false;
                
                if (MySheet.Cells[index, 1].Value != null) {
                    opration = (string)(MySheet.Cells[index, 1].Value.ToString());
                    t.OprationID = opration;
                    _hasData = true;
                   // Debug.WriteLine(opration);

                }
               

              

                if (MySheet.Cells[index, 2].Value != null)
                {
                    _OprationName = (string)(MySheet.Cells[index, 2].Value.ToString());
                    t.OparationName = _OprationName;
                    if (MySheet.Cells[index, 1].Value != null)
                    {

                    }
                    else {
                        t.PartName = t.OparationName;
                       
                    }
                   

                }

             if (MySheet.Cells[index, 3].Value != null)
                {
                    _MachineType = (string)(MySheet.Cells[index, 3].Value.ToString());
                    t.MachineType = _MachineType;
                   // Debug.WriteLine(opration);

                }

            if (MySheet.Cells[index, 4].Value != null)
                {
                    _SMVtype = (string)(MySheet.Cells[index, 4].Value.ToString());
                    t.SMVType = _SMVtype;
                   // D ebug.WriteLine(opration);

                }

            if (MySheet.Cells[index, 6].Value != null)
                {
                    _SMV = (string)(MySheet.Cells[index, 6].Value.ToString());
                    _SMVtype = "M/C";


                    try {
                        t.SMV = Convert.ToDouble(_SMV);
                        t.SMVType = _SMVtype;
                    }
                catch(Exception ex){
                    t.SMV = 0;
                    t.SMVType = _SMVtype;
                    Debug.WriteLine(ex.Message);
                }
                 
                   // D ebug.WriteLine(opration);

                }


                 if (MySheet.Cells[index, 7].Value != null)
                {
                    _SMV = (string)(MySheet.Cells[index, 7].Value.ToString());
                    _SMVtype = "M/A";

                    try {
                        t.SMV = Convert.ToDouble(_SMV);
                        t.SMVType = _SMVtype;
                    }
                     catch(Exception ex){
                         t.SMV = 0;
                         t.SMVType = _SMVtype;
                         Debug.WriteLine(ex.Message);
                     }
                
                   // D ebug.WriteLine(opration);

                }

                 if (MySheet.Cells[index, 8].Value != null)
                 {
                     _OprationRole = (string)(MySheet.Cells[index, 8].Value.ToString());
                     t.OprationRole = _OprationRole;
                     // D ebug.WriteLine(opration);

                 }
                 else {
                     t.OprationRole ="None";
                 }

                 if (MySheet.Cells[index, 9].Value != null)
                 {
                     _OprationGrade = (string)(MySheet.Cells[index, 9].Value.ToString());
                     t.OprationGrade = _OprationGrade;
                     // D ebug.WriteLine(opration);

                 }
                 else {
                     t.OprationGrade = "None";
                 }

                 GenaricRepository<TempOpration> _TempOprationRepository = new GenaricRepository<TempOpration>(new ItrackContext());
               
                bar.PerformStep();
               
                if (_hasData == true && GetoprationByID(t.OprationID).Count == 0)
                {

                    
                    _TempOprationRepository.Insert(t);
                }

                //oprationList.Add(new OperationPool
                // {

                //     OperationPoolID = MyValues.GetValue(1, 1).ToString(),
                //     OpationName = MyValues.GetValue(1, 2).ToString(),
                //     MachineType = MyValues.GetValue(1, 3).ToString(),
                //     SMVType = MyValues.GetValue(1, 4).ToString(),
                //     SMV = Convert.ToDouble(MyValues.GetValue(1, 4).ToString())
                // });


                                        

                
            }

            bar.Hide();
            
            return oprationList;
        }