Esempio n. 1
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;
        }
       public static async Task<bool> DoDayend(  Label lbl,DevExpress.XtraWaitForm.ProgressPanel pnl,DateTime _now) {
           try {

               lbl.Text = "Calculating Production Figures..";
               pnl.Show();
               await Task.Run(() =>
               {
                 
                   

                //   AddIndividualProductionSummary(_now,txt);
               
               });

               lbl.Text = "Sucecessfuly Completed !";
               pnl.Hide();
               return true;
           }
           catch(Exception ex){
               Debug.WriteLine(ex.Message);
               return false;
           }
       }