Ejemplo n.º 1
0
 public AddDbUserForm(DbConnect dbc)
 {
     InitializeComponent();
     for (int i =access_level_start_index;i<=dbc.CurrUser.AccessLevel;i++)
     {
         this.comboBox1.Items.Add(i);
     }
     if(comboBox1.Items.Count>0)
         comboBox1.SelectedIndex=0;
     if (comboBoxWithInputCheck1.Items.Count > 0)
         comboBoxWithInputCheck1.SelectedIndex = 0;
     dbc.SelectFrom("*", "employee_customer_selection", dt);
     comboBoxWithInputCheck1.DataSource = dt;
     comboBoxWithInputCheck1.ValueMember = "id";
     comboBoxWithInputCheck1.DisplayMember = "data";
     this.postgreConnection = dbc;
 }
Ejemplo n.º 2
0
        public void DrawData(int oper, double number, DbConnect pgc, string from,string formName =null)
        {
            if (formName != null)
            {
                this.Text = formName;
                button3.Enabled = true;
            }
            bool compRes = false;
            chart1.Series.Clear();
            Series sIncome = new Series(), sExpenses = new Series();
            sIncome.ChartType = sExpenses.ChartType = SeriesChartType.Line;
            DataTable dt = new DataTable();
            DataPoint dp = new DataPoint();
            DataTable ordersTable = new DataTable();
            pgc.SelectFrom("*", from, ordersTable);
            sIncome.LegendText = "Доход";
            sIncome.Color = Color.Blue;
            sExpenses.Color = Color.Red;
            sExpenses.LegendText = "Расход";
            foreach (DataRow dr in ordersTable.Rows)
            {
                dp = new DataPoint();
                dp.Color = Color.Blue;
                dp.MarkerSize = 5;
                dp.MarkerColor = Color.Blue;
                dp.MarkerStyle = MarkerStyle.Circle;
                dp.IsEmpty = false;
                pgc.SelectFromFunc("*", "order_expenses_income", dr.ItemArray[0].ToString(), dt);
                if (oper != -1 && number > 0)
                    if (Compare(oper, number, dt.Rows[0].ItemArray[0]) && Compare(oper, number, dt.Rows[0].ItemArray[1]))
                        compRes = true;
                    else
                        compRes = false;
                if ((compRes) || (oper == -1 && number ==-1))
                {
                    try
                    {
                        dp.SetValueXY(DateTime.Parse(dr.ItemArray[6].ToString()), dt.Rows[0].ItemArray[0]);
                        dp.Label = DateTime.Parse(dr.ItemArray[6].ToString()).ToShortDateString() + " " + dr.ItemArray[9].ToString();
                        sIncome.Points.Add(dp);
                    }
                    catch
                    {

                    }
                    dp = new DataPoint();
                    dp.Color = Color.Red;
                    dp.MarkerSize = 5;
                    dp.MarkerColor = Color.Red;
                    dp.MarkerStyle = MarkerStyle.Circle;
                    dp.IsEmpty = false;
                    dp.SetValueXY(DateTime.Parse(dr.ItemArray[6].ToString()), dt.Rows[0].ItemArray[1]);
                    dp.Label = DateTime.Parse(dr.ItemArray[6].ToString()).ToShortDateString() + " " + dr.ItemArray[9].ToString();
                    sExpenses.Points.Add(dp);
                }
                dt.Clear();
            }
            sExpenses.XValueType = ChartValueType.Date;
            sIncome.XValueType = ChartValueType.Date;
            //chart1.ChartAreas[0].AxisX.ScaleView.Zoom(0, 10);
            chart1.Series.Add(sExpenses);
            chart1.Series.Add(sIncome);
            chart1.ChartAreas[0].RecalculateAxesScale();
        }