Пример #1
0
        private void button_tra_cuu_Click(object sender, EventArgs e)
        {
            if (comboBox_thang.Text == "" || textBox_nam.Text == "")
            {
                MessageBox.Show("Bạn chưa điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                DataTable _dt = busCTDoanhthuthang.Get_by_MON_and_Year(comboBox_thang.Text.ToString(), textBox_nam.Text.ToString());

                _dt.Columns.Add("Tỷ lệ (%)", typeof(float));
                _dt.Columns["Tỷ lệ (%)"].SetOrdinal(4);

                int index = _dt.Rows.Count;

                for (int i = 0; i < index; i++)
                {
                    dem += int.Parse(busTinhtrangve.Get_SL_GHE_by_MACB(_dt.Rows[i][1].ToString()));
                    dem2 = float.Parse(busVechuyenbay.Get_SLVE_MUA_by_MACB_MONTH(_dt.Rows[i][1].ToString(), comboBox_thang.Text));

                    //_dt.Rows[i][4] = (float.Parse(busTinhtrangve.Get_SL_GHE_by_MACB(_dt.Rows[i][1].ToString()))
                    //    / 100 * float.Parse(busVechuyenbay.Get_SLVE_MUA_by_MACB_MONTH(_dt.Rows[i][1].ToString(),dem2.ToString())));

                    _dt.Rows[i][4] = (float.Parse(busTinhtrangve.Get_SL_GHE_by_MACB(_dt.Rows[i][1].ToString()))
                                      / 100 * dem2);
                }

                dataGridView_dthu.DataSource = _dt;

                dataGridView_dthu.Sort(dataGridView_dthu.Columns[0], ListSortDirection.Ascending);
                dataGridView_dthu.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView_dthu.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.None;
            }
        }
Пример #2
0
        private void button_tra_cuu_Click(object sender, EventArgs e)
        {
            if (textBox_nam.Text == "")
            {
                MessageBox.Show("Bạn chưa điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                DataTable _dt = busDoanhthuthang.Get_report_by__Year(textBox_nam.Text.ToString());

                _dt.Columns.Add("Tỷ lệ (%)", typeof(float));
                _dt.Columns["Tỷ lệ (%)"].SetOrdinal(4);

                int index = _dt.Rows.Count;



                for (int i = 0; i < index; i++)
                {
                    DataTable _dt2 = busCTDoanhthuthang.Get_by_MON_and_Year(_dt.Rows[i][1].ToString(), textBox_nam.Text.ToString());



                    _dt2.Columns.Add("Tỷ lệ (%)", typeof(float));
                    _dt2.Columns["Tỷ lệ (%)"].SetOrdinal(4);

                    int index2 = _dt2.Rows.Count;

                    for (int j = 0; j < index2; j++)
                    {
                        // int tmmp = busTinhtrangve.Get_SL_GHE_by_MACB(_dt2)

                        //tongsl_ve += int.Parse(busTinhtrangve.Get_SL_GHE_by_MACB(_dt2.Rows[j][1].ToString()));
                        //tongsl_ve_mua += int.Parse(busVechuyenbay.Get_SLVE_MUA_by_MACB(_dt2.Rows[j][1].ToString()));

                        k1 += float.Parse(busTinhtrangve.Get_SL_GHE_by_MACB(_dt2.Rows[j][1].ToString()));
                        k2 += float.Parse(busVechuyenbay.Get_SLVE_MUA_by_MACB(_dt2.Rows[j][1].ToString()));
                    }

                    //_dt.Rows[i][4] = (float.Parse(tongsl_ve)) / 100 * float.Parse(tongsl_ve_mua);
                    _dt.Rows[i][4] = k1 / 100 * k2;

                    k1 = 0;
                    k2 = 0;
                }

                decimal _value = Convert.ToDecimal(busDoanhthunam.Get_doanhthu_NAM(textBox_nam.Text));
                if (_value != 0)
                {
                    String.Format("{0:n0}", _value);
                    label_doanhthu_nam.Text = string.Format("{0:0,0}", _value);
                }
                if (_value == 0)
                {
                    label_doanhthu_nam.Text = busDoanhthunam.Get_doanhthu_NAM(textBox_nam.Text);
                }


                dataGridView_dthu.DataSource = _dt;


                dataGridView_dthu.Sort(dataGridView_dthu.Columns[0], ListSortDirection.Ascending);
                dataGridView_dthu.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView_dthu.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.None;
                textBox_nam.Text = "";
            }
        }