Ejemplo n.º 1
0
        public static async Task<bool> ReadDevidingPlan() {

            try {

                DividingPlanTemp temp = new DividingPlanTemp();
                bool _hasData= false;


                if (MySheet.Cells[4, 2].Value != null)
                {
                    temp.StyleID = (string)(MySheet.Cells[4, 2].Value.ToString());

                    _hasData = true;
                    // Debug.WriteLine(opration);

                }

                if (MySheet.Cells[4, 4].Value != null)
                {
                    temp.LineNo = (string)(MySheet.Cells[4, 4].Value.ToString());

                    _hasData = true;
                    // Debug.WriteLine(opration);

                }


                if (MySheet.Cells[5, 6].Value != null)
                {
                    temp.Target = (string)(MySheet.Cells[5, 6].Value.ToString());

                    _hasData = true;
                  

                }

                if (MySheet.Cells[4, 6].Value != null)
                {
                    string i = (string)(MySheet.Cells[4, 6].Value.ToString());
                    temp.TotalEmployee = i;

                
                    // Debug.WriteLine(opration);

                }
 
                if (MySheet.Cells[6, 6].Value != null)
                {
                    temp.ProductionPerHour = (string)(MySheet.Cells[6, 6].Value.ToString());

                    _hasData = true;
                    // Debug.WriteLine(opration);

                }

                for (int index = 9; index <= lastRow; index++)
                {

                    if (MySheet.Cells[index, 1].Value != null)
                    {
                        temp.OprationNo = (string)(MySheet.Cells[index, 1].Value.ToString());

                        _hasData = true;
                        // Debug.WriteLine(opration);

                    }
                    else {
                        temp.OprationNo = "";
                        _hasData = false;
                    }

                    if (MySheet.Cells[index, 2].Value != null)
                    {
                        temp.OprationName = (string)(MySheet.Cells[index, 2].Value.ToString());


                        // Debug.WriteLine(opration);

                    }
                    else {
                        temp.OprationName = "";
                    }



                    if (MySheet.Cells[index, 3].Value != null)
                    {
                        temp.MachineType = (string)(MySheet.Cells[index, 3].Value.ToString());


                        // Debug.WriteLine(opration);

                    }
                    else {

                        temp.MachineType = "";
                    }

                    if (MySheet.Cells[index, 4].Value != null)
                    {
                        temp.SMV = (string)(MySheet.Cells[index, 4].Value.ToString());
                        temp.SMVType = "M/C";


                        try
                        {
                            temp.SMV = temp.SMV;
                            temp.SMVType = temp.SMVType;
                        }
                        catch (Exception ex)
                        {
                            temp.SMV = "0";
                            temp.SMVType = temp.SMVType;
                            Debug.WriteLine(ex.Message);
                        }

                        // D ebug.WriteLine(opration);

                    }


                    if (MySheet.Cells[index, 5].Value != null)
                    {
                        temp.SMV = (string)(MySheet.Cells[index, 5].Value.ToString());
                        temp.SMVType = "M/A";
                          temp.MachineType ="None";

                        try
                        {
                            temp.SMV = temp.SMV;
                            temp.SMVType = temp.SMVType;
                        }
                        catch (Exception ex)
                        {
                            temp.SMV = "0";
                            temp.SMVType = temp.SMVType;
                            Debug.WriteLine(ex.Message);
                        }

                        // D ebug.WriteLine(opration);

                    }
                    GenaricRepository<DividingPlanTemp> _DevidingPlanRepository = new GenaricRepository<DividingPlanTemp>(new ItrackContext());
               
                    if (_hasData) {
                        _DevidingPlanRepository.Insert(temp);
                        Debug.WriteLine(temp.OprationNo + " | " + temp.OprationName + " | " + temp.MachineType + " | " + temp.SMVType + " | " + temp.SMV);
               
                    }
                  
                  
                }

                return true;
            }
            catch(Exception ex){
                Debug.WriteLine(ex.Message);
                return false;
            }
        } 
Ejemplo n.º 2
0
        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);
            }
        }