public void LoadProducts()
        {
            listProducts = productModel.getProductsToSale();
            DataTable dtProduct = ConvertCustom.ListToDataTable <TblProductsDTO>(listProducts);

            bsProduct = new BindingSource()
            {
                DataSource = dtProduct
            };

            //binding data to data grid view
            form.getBnProduct().BindingSource = bsProduct;
            form.getDgvProduct().DataSource   = bsProduct;

            //hide unessesary column
            form.getDgvProduct().Columns["idProduct"].Visible    = false;
            form.getDgvProduct().Columns["status"].Visible       = false;
            form.getDgvProduct().Columns["idCategory"].Visible   = false;
            form.getDgvProduct().Columns["categoryName"].Visible = false;

            List <TblCategoryDTO> listCategory = categoryModel.getAll();

            foreach (var category in listCategory)
            {
                form.getCmbCategory().Items.Add(category.name);
            }

            foreach (DataGridViewColumn column in form.getDgvProduct().Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        }
        public void getAllProduct()
        {
            try
            {
                List <TblProductsDTO> listProducts = productModel.getProducts();
                DataTable             dataTable    = ConvertCustom.ListToDataTable(listProducts);
                bindingSourceProduct = new BindingSource()
                {
                    DataSource = dataTable
                };

                form.GetBindingNavigatorProduct().BindingSource             = bindingSourceProduct;
                form.GetDataGridViewProduct().DataSource                    = bindingSourceProduct;
                form.GetDataGridViewProduct().Columns["idProduct"].Visible  = false;
                form.GetDataGridViewProduct().Columns["idCategory"].Visible = false;
                form.GetDataGridViewProduct().Columns["status"].Visible     = false;
                form.GetComboBoxTable().DataSource    = bindingSourceCategory;
                form.GetComboBoxTable().DisplayMember = "name";
                form.GetComboBoxTable().ValueMember   = "idCategory";
                clearDataBindingTextProduct();
                bindingDataTextProduct();
            }
            catch (Exception e)
            {
                MessageBox.Show(MessageUtil.ERROR + " Get All Product" + e.Message);
            }
        }
        public void LoadCustomers()
        {
            List <TblCustomerDTO> listCustomers = customerModel.getCustomers();

            if (listCustomers != null)
            {
            }
            DataTable dtCustomer = ConvertCustom.ListToDataTable <TblCustomerDTO>(listCustomers);

            bsCustomer = new BindingSource()
            {
                DataSource = dtCustomer
            };

            //binding data to data grid view
            form.getBnCustomer().BindingSource = bsCustomer;
            form.getDgvCustomer().DataSource   = bsCustomer;

            //hide unnecessary column
            form.getDgvCustomer().Columns["phone"].Visible   = false;
            form.getDgvCustomer().Columns["address"].Visible = false;
            form.getDgvCustomer().Columns["point"].Visible   = false;

            //clear and add new data binding
            clearDataBindingTextCustomer();
            bindingDataTextCustomer();
        }
        public void SearchRevenues(DateTime date)
        {
            float total = orderModel.LoadTotal(date);
            List <RevenuesDTO> listDetail = orderModel.LoadOrderDetail(date);

            if (listDetail != null)
            {
                DataTable dtOrderDetail = ConvertCustom.ListToDataTable <RevenuesDTO>(listDetail);
                bsOrderdetail = new BindingSource()
                {
                    DataSource = dtOrderDetail
                };

                //binding data to data grid view
                form.getBnOrderDetail().BindingSource = bsOrderdetail;
                form.getDgvOrderDetail().DataSource   = bsOrderdetail;
                form.gettotal().Text = total.ToString();
                //hide unnecessary column
                form.getDgvOrderDetail().Columns["Customer"].Visible = false;
                form.getDgvOrderDetail().Columns["Salesman"].Visible = false;
                form.getDgvOrderDetail().Columns["total"].Visible    = false;

                //clear and add new data binding
                clearDataBindingTextOrderdetail();
                bindingDataTextOrderdetail();
            }
        }
 public void loadEmp()
 {
     try
     {
         List <TblEmployeesDTO> listEmp = model.getAll();
         DataTable dataTable            = ConvertCustom.ListToDataTable(listEmp);
         bsEmp = new BindingSource()
         {
             DataSource = dataTable
         };
         bindingSource();
     }
     catch (Exception e)
     {
         MessageBox.Show(MessageUtil.ERROR + " Get All Employee");
     }
 }
 public void LoadEmpByRole(frmManager_v2 form)
 {
     try
     {
         string role = form.getRole();
         List <TblEmployeesDTO> list = model.LoadEmpByRole(role);
         DataTable dataTable         = ConvertCustom.ListToDataTable(list);
         bsEmp = new BindingSource()
         {
             DataSource = dataTable
         };
         bindingSource();
     }
     catch (Exception e)
     {
         MessageBox.Show(MessageUtil.ERROR + " Load Employee By Role");
     }
 }
 public void getAllCategory()
 {
     try
     {
         List <TblCategoryDTO> categoryDTOs = categoryModel.getAll();
         DataTable             dataTable    = ConvertCustom.ListToDataTable(categoryDTOs);
         bindingSourceCategory = new BindingSource()
         {
             DataSource = dataTable
         };
         form.GetDataGridViewCategory().DataSource = bindingSourceCategory;
         form.GetDataGridViewCategory().Columns["idCategory"].Visible = false;
         form.GetBindingNavigatorCategory().BindingSource             = bindingSourceCategory;
         clearDataBindingTextCategory();
         bindingDataTextCategory();
     }
     catch (Exception e)
     {
         MessageBox.Show(MessageUtil.ERROR + " Get All Category");
     }
 }
        public void LoadProductsOrder()
        {
            if (listProductOrder == null)
            {
                form.getDgvItemOfOrder().DataSource = null;
                form.getDgvItemOfOrder().Rows.Clear();
                return;
            }

            DataTable dtProduct = ConvertCustom.ListToDataTable <CartItemDTO>(listProductOrder);

            //binding data to data grid view
            form.getDgvItemOfOrder().DataSource = dtProduct;

            form.getDgvItemOfOrder().Columns["idProduct"].Visible = false;

            foreach (DataGridViewColumn column in form.getDgvItemOfOrder().Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
        }
        private void SheetTrajectory(ref XLWorkbook workbook)
        {
            // This is invariant
            NumberFormatInfo format = new NumberFormatInfo();

            // Set the 'splitter' for thousands
            format.NumberGroupSeparator = ".";
            // Set the decimal seperator
            format.NumberDecimalSeparator = ",";

            string sheetName = "Trajectory";

            var worksheet01 = workbook.Worksheets.Add(sheetName);

            int numberLines = ExtendedStreamReader.LinesOfFile(dirServerDebug + @"\" + debugFile);

            //DADOS
            string            line;
            List <Trajectory> trajectory = new List <Trajectory>();
            int _MCStep = 0;

            using (ExtendedStreamReader file = new ExtendedStreamReader(dirServerDebug + @"\" + debugFile, this.param.dataToProcess.Guid, this.param.dataToProcess.crypt))
            {
                double rg = 0;   //Calculo acumulado do Raio de GIração

                int cont = 0;    //Contador
                                 //int lastMove = 0; //valor do último movimento
                int contAdd = 1; //contador adicional



                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    if (cont > 0)
                    {
                        string[] col = line.Split('\t');

                        int numberMov = ConvertCustom.ToInt32(col[0]);

                        if (numberMov < (delta * contAdd) + 1)
                        {
                            rg     += double.Parse(col[3], format); //coluna no qual contêm valor do raio de giração
                            _MCStep = ConvertCustom.ToInt32(col[0]);
                        }
                        else
                        {
                            double value = ((double)1 / delta) * rg;
                            trajectory.Add(new Trajectory()
                            {
                                MCStep = _MCStep, rg = value
                            });
                            contAdd++;
                            rg  = 0;
                            rg += Convert.ToDouble(col[3]); //coluna no qual contêm valor do raio de giração
                        }
                    }

                    cont++;
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS


            //DATASHEET
            worksheet01.Cell("A1").Value = sheetName;

            worksheet01.Cell("A2").Value = "lines";
            worksheet01.Cell("B2").Value = numberLines;

            worksheet01.Cell("A3").Value = "MCSteps";
            worksheet01.Cell("B3").Value = MCSteps;

            worksheet01.Cell("A4").Value = "delta";
            worksheet01.Cell("B4").Value = delta;

            worksheet01.Cell("A5").Value = "idx";
            worksheet01.Cell("B5").Value = "MCSteps";
            worksheet01.Cell("C5").Value = "SUM((1 / delta) * md)";

            for (int i = 0; i < trajectory.Count; i++)
            {
                double value = trajectory[i].rg;
                _MCStep = trajectory[i].MCStep;
                worksheet01.Cell("A" + (i + 6)).Value = i;
                worksheet01.Cell("B" + (i + 6)).Value = _MCStep;
                worksheet01.Cell("C" + (i + 6)).Value = value;
            }
        }
        private void SheetDistribution(ref XLWorkbook workbook)
        {
            // This is invariant
            NumberFormatInfo format = new NumberFormatInfo();

            // Set the 'splitter' for thousands
            format.NumberGroupSeparator = ".";
            // Set the decimal seperator
            format.NumberDecimalSeparator = ",";

            string sheetName = "Distribution";
            string fileName  = "Distribution.dat";
            string mask      = "";

            var worksheet01 = workbook.Worksheets.Add(sheetName);

            //DADOS
            string        line;
            List <string> lines = new List <string>();

            using (ExtendedStreamReader file = new ExtendedStreamReader(dirWebExcel + @"\" + fileName, this.param.dataToProcess.Guid, false))
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    lines.Add(line);
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS

            //HEADER
            worksheet01.Cell("A1").Value = sheetName;
            worksheet01.Cell("B1").Value = mask;
            worksheet01.Cell("C1").Value = mask;
            worksheet01.Cell("D1").Value = "idx";
            worksheet01.Cell("E1").Value = "mcStep";
            worksheet01.Cell("F1").Value = "rg2";
            worksheet01.Cell("G1").Value = "rg2(accumulated)";
            worksheet01.Cell("H1").Value = "<rg2>";
            worksheet01.Cell("I1").Value = "e";
            worksheet01.Cell("J1").Value = "e(accumulated)";
            worksheet01.Cell("K1").Value = "<e>";
            worksheet01.Cell("L1").Value = "U";
            worksheet01.Cell("M1").Value = "U(accumulated)";
            worksheet01.Cell("N1").Value = "<U>";

            //INFOS
            string comment = string.Empty;
            double value   = 0;
            int    i       = 0;

            //DATA
            long   idx, mcstep = 0;
            double rg, U, eE, eRG, eU, e, aE, aU, aRG;

            rg = U = eE = eRG = eU = e = aE = aU = aRG = 0;

            //PRIMEIRA PARTE COM HEADER
            for (i = 0; i < 8; i++)
            {
                string[] temp = lines[i].Split(':');
                comment = ConvertCustom.ToString(temp[0]);
                worksheet01.Cell("A" + (i + 2)).Value = comment;

                try
                {
                    value = ConvertCustom.ToDouble(temp[1]);
                    worksheet01.Cell("B" + (i + 2)).Value = value;
                }
                catch (FormatException)
                {
                    string strValue = Convert.ToString(temp[1]);
                    worksheet01.Cell("B" + (i + 2)).Value = strValue;
                }


                string[] tempResult = lines[i + 9].Split('\t');
                idx    = ConvertCustom.ToInt32(tempResult[0]);
                mcstep = ConvertCustom.ToInt32(tempResult[1]);

                rg  = double.Parse(tempResult[2], format);
                aRG = double.Parse(tempResult[3], format);
                eRG = double.Parse(tempResult[4], format);

                e  = double.Parse(tempResult[5], format);
                aE = double.Parse(tempResult[6], format);
                eE = double.Parse(tempResult[7], format);

                U  = double.Parse(tempResult[8], format);
                aU = double.Parse(tempResult[9], format);
                eU = double.Parse(tempResult[10], format);

                worksheet01.Cell("C" + (i + 2)).Value = mask;
                worksheet01.Cell("D" + (i + 2)).Value = idx;
                worksheet01.Cell("E" + (i + 2)).Value = mcstep;
                worksheet01.Cell("F" + (i + 2)).Value = rg;
                worksheet01.Cell("G" + (i + 2)).Value = aRG;
                worksheet01.Cell("H" + (i + 2)).Value = eRG;
                worksheet01.Cell("I" + (i + 2)).Value = e;
                worksheet01.Cell("J" + (i + 2)).Value = aE;
                worksheet01.Cell("K" + (i + 2)).Value = eE;
                worksheet01.Cell("L" + (i + 2)).Value = U;
                worksheet01.Cell("M" + (i + 2)).Value = aU;
                worksheet01.Cell("N" + (i + 2)).Value = eU;
            }

            //SEGUNDA PARTE
            for (int j = i; j < (lines.Count() - 9); j++)
            {
                worksheet01.Cell("A" + (j + 2)).Value = mask;
                worksheet01.Cell("B" + (j + 2)).Value = mask;
                worksheet01.Cell("C" + (j + 2)).Value = mask;

                string[] tempResult = lines[j + 9].Split('\t');
                idx    = ConvertCustom.ToInt32(tempResult[0]);
                mcstep = ConvertCustom.ToInt32(tempResult[1]);

                rg  = double.Parse(tempResult[2], format);
                aRG = double.Parse(tempResult[3], format);
                eRG = double.Parse(tempResult[4], format);

                e  = double.Parse(tempResult[5], format);
                aE = double.Parse(tempResult[6], format);
                eE = double.Parse(tempResult[7], format);

                U  = double.Parse(tempResult[8], format);
                aU = double.Parse(tempResult[9], format);
                eU = double.Parse(tempResult[10], format);


                worksheet01.Cell("D" + (j + 2)).Value = idx;
                worksheet01.Cell("E" + (j + 2)).Value = mcstep;
                worksheet01.Cell("F" + (j + 2)).Value = rg;
                worksheet01.Cell("G" + (j + 2)).Value = aRG;
                worksheet01.Cell("H" + (j + 2)).Value = eRG;
                worksheet01.Cell("I" + (j + 2)).Value = e;
                worksheet01.Cell("J" + (j + 2)).Value = aE;
                worksheet01.Cell("K" + (j + 2)).Value = eE;
                worksheet01.Cell("L" + (j + 2)).Value = U;
                worksheet01.Cell("M" + (j + 2)).Value = aU;
                worksheet01.Cell("N" + (j + 2)).Value = eU;
            }
            lines = null;
            //FIM DATASHEET
        }