Exemple #1
0
        //Прибыль
        public void PeriodProfid(DateTime begin, DateTime end)
        {
            if ((end - begin).Days <= 5)
            {
                string beginDate = begin.ToString("yyyy-MM-dd");
                string endDate   = end.ToString("yyyy-MM-dd");

                //excel = new Application();
                //excel.Visible = true;
                //excel.Workbooks.Add();
                //Microsoft.Office.Interop.Excel.Worksheet workSheet = (Microsoft.Office.Interop.Excel.Worksheet)excel.ActiveSheet;
                ExcelClass excel_class = new ExcelClass();
                excel_class.Open(System.Windows.Forms.Application.StartupPath + "\\reports\\period_expense1.xls");


                MySqlCommand command = new MySqlCommand();
                command.Connection  = connection;
                command.CommandText = GetQueryExpense(beginDate, endDate);
                System.Data.DataTable tableExpense = new System.Data.DataTable();
                System.Data.DataTable tableRealize = new System.Data.DataTable();
                MySqlDataAdapter      adapter      = new MySqlDataAdapter(command);
                adapter.Fill(tableExpense);
                command.CommandText = GetQueryRealize();
                adapter.Fill(tableRealize);

                excel_class.ColWidth("B", 50);
                int i = 7;
                foreach (DataRow dr in tableExpense.Rows)
                {
                    DataRow[] dr1 = tableRealize.Select("productId = " + dr["productId"]);
                    if (dr["productId"].ToString() == "2635")
                    {
                    }
                    excel_class.SetCell("A" + i, dr["productId"].ToString(), false);
                    excel_class.SetCell("B" + i, dr["name"].ToString(), false);
                    //if (dr["measureId"].ToString() == "2")
                    //    excel_class.SetCell("C" + i, "ШТ", false);
                    //else
                    //    excel_class.SetCell("C" + i, "КГ", false);

                    excel_class.SetCell("E" + i, dr["SumCount"].ToString(), false);
                    excel_class.SetCell("F" + i, dr["SumOrder"].ToString(), false);
                    if (dr1.Length != 0)
                    {
                        double raznica = double.Parse(dr1[0]["soldPrice"].ToString()) - double.Parse(dr1[0]["price"].ToString());
                        excel_class.SetCell("G" + i, (double.Parse(dr["SumCount"].ToString()) * raznica).ToString(), false);
                    }
                    i++;
                }

                excel_class.activeSheet.Application.Visible = true;
            }



            //workSheet.get_Range("A").ColumnWidth = 35;
        }
Exemple #2
0
        public void Selling(DateTime beginDate, DateTime endDate)
        {
            string dateBegin = beginDate.ToString("yyyy-MM-dd");
            string dateEnd   = endDate.ToString("yyyy-MM-dd");

            //excel = new Application();
            //excel.Visible = true;
            //excel.Workbooks.Add();
            //Microsoft.Office.Interop.Excel.Worksheet workSheet = (Microsoft.Office.Interop.Excel.Worksheet)excel.ActiveSheet;
            ExcelClass excel_class = new ExcelClass();

            excel_class.Open(System.Windows.Forms.Application.StartupPath + "\\reports\\period_saldo.xls");


            MySqlCommand command = new MySqlCommand();

            command.Connection  = connection;
            command.CommandText = GetQueryReport2(dateBegin, dateEnd);
            System.Data.DataTable tableReport = new System.Data.DataTable();
            MySqlDataAdapter      adapter     = new MySqlDataAdapter(command);

            adapter.Fill(tableReport);
            //command.CommandText = GetQueryExpense(dateBegin, dateEnd);
            //adapter.Fill(tableExpense);

            excel_class.ColWidth("B", 50);

            int i = 7;

            //DataRow[] rBalanceSaldo = tableBalanceList.Select("balanceDate = '"+dateBegin+"'");
            //DataRow[] rBalanceOstatok = tableBalanceList.Select("balanceDate = '" + dateEnd + "'");

            foreach (DataRow dr in tableReport.Rows)
            {
                excel_class.SetCell("A" + i, dr["productId"].ToString(), false);
                excel_class.SetCell("B" + i, dr["name"].ToString(), false);
                excel_class.SetCell("D" + i, dr["saldoCount"].ToString(), false);
                excel_class.SetCell("E" + i, dr["price"].ToString(), false);

                excel_class.SetCell("F" + i, Math.Round(double.Parse(dr["saldoCount"].ToString()) * double.Parse(dr["price"].ToString()), 3).ToString(), false);

                excel_class.SetCell("G" + i, dr["prixCount"].ToString(), false);
                excel_class.SetCell("H" + i, dr["prPrice"].ToString(), false);
                if (dr["prixCount"] != DBNull.Value)
                {
                    excel_class.SetCell("I" + i, Math.Round(double.Parse(dr["prixCount"].ToString()) * double.Parse(dr["prPrice"].ToString()), 3).ToString(), false);
                }

                excel_class.SetCell("K" + i, dr["spisCount"].ToString(), false);
                excel_class.SetCell("L" + i, dr["spisSumm"].ToString(), false);
                if (dr["spisCount"] != DBNull.Value)
                {
                    excel_class.SetCell("M" + i, Math.Round(double.Parse(dr["spisCount"].ToString()) * double.Parse(dr["spisSumm"].ToString()), 3).ToString(), false);
                }
                excel_class.SetCell("N" + i, dr["exCount"].ToString(), false);
                excel_class.SetCell("O" + i, dr["exSumm"].ToString(), false);
                if (dr["exCount"] != DBNull.Value)
                {
                    excel_class.SetCell("P" + i, Math.Round(double.Parse(dr["exCount"].ToString()) * double.Parse(dr["exSumm"].ToString()), 3).ToString(), false);
                }

                excel_class.SetCell("Q" + i, dr["backCount"].ToString(), false);
                excel_class.SetCell("R" + i, dr["backSumm"].ToString(), false);
                if (dr["backCount"] != DBNull.Value)
                {
                    excel_class.SetCell("S" + i, Math.Round(double.Parse(dr["backCount"].ToString()) * double.Parse(dr["backSumm"].ToString()), 3).ToString(), false);
                }

                excel_class.SetCell("T" + i, dr["ostatokCount"].ToString(), false);
                excel_class.SetCell("U" + i, dr["price"].ToString(), false);
                if (dr["ostatokCount"] != DBNull.Value)
                {
                    excel_class.SetCell("V" + i, Math.Round(double.Parse(dr["ostatokCount"].ToString()) * double.Parse(dr["price"].ToString()), 3).ToString(), false);
                }
                i++;
            }
            excel_class.activeSheet.Application.Visible = true;
        }