Ejemplo n.º 1
0
        private void dgvvibor_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 32)
            {
                int i = dgvvibor.CurrentRow.Index;
                switch (Sform.ownerFormName)
                {
                case "Pform":
                    CallBackMy.callbackEventHandlerPform(dgvvibor.Rows[i].Cells["Kod"].Value.ToString());
                    break;

                case "Tform":
                    CallBackMy.callbackEventHandlerTform(dgvvibor.Rows[i].Cells["Kod"].Value.ToString());
                    break;

                case "Pereocenkaform":
                    CallBackMy.callbackEventHandlerPereocenkaform(dgvvibor.Rows[i].Cells["Kod"].Value.ToString());
                    break;

                case "Rform":
                    CallBackMy.callbackEventHandlerRform(dgvvibor.Rows[i].Cells["Kod"].Value.ToString());
                    break;

                default:
                    break;
                }


                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void ImportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string formactive = ActiveForm.Text;

            if (formactive.IndexOf("Расходная накладная") >= 0)
            {
                //Создаем новый экземпляр
                List <ImportExport> CSV_Struct = new List <ImportExport>();
                CSV_Struct = ImportExport.ImportToCsv();

                string message   = "Загружено: " + CSV_Struct.Count + " позиций";
                int    countmess = 5;
                if (CSV_Struct.Count <= 5)
                {
                    countmess = CSV_Struct.Count;
                }
                for (int i = 0; i <= countmess - 1; i++)
                {
                    message += Environment.NewLine + CSV_Struct[i].kod + " -- " + CSV_Struct[i].qty;
                }

                DialogResult result = MessageBox.Show(message, "Загрузить данные?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    //Заполняем listView из нашей структуры
                    for (int i = 0; i <= CSV_Struct.Count - 1; i++)
                    {
                        CallBackMy.callbackEventHandlerRform(CSV_Struct[i].kod);
                        CallBackMy.callbackEventHandlerRformImport(CSV_Struct[i].kod, Convert.ToDouble(CSV_Struct[i].qty));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void dgvFindT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (dgvFindT.RowCount > 0)
            {
                if (e.KeyChar == 32)
                {
                    int irow = dgvFindT.CurrentRow.Index;

                    switch (Sform.ownerFormName)
                    {
                    case "Pform":
                        CallBackMy.callbackEventHandlerPform(dgvFindT.Rows[irow].Cells[0].Value.ToString());
                        exitfrm = "func";
                        this.Close();
                        break;

                    case "Tform":
                        CallBackMy.callbackEventHandlerTform(dgvFindT.Rows[irow].Cells[0].Value.ToString());
                        this.Close();
                        break;

                    case "Pereocenkaform":
                        CallBackMy.callbackEventHandlerPereocenkaform(dgvFindT.Rows[irow].Cells[0].Value.ToString());
                        exitfrm = "func";
                        this.Close();
                        break;

                    case "Rform":
                        CallBackMy.callbackEventHandlerRform(dgvFindT.Rows[irow].Cells[0].Value.ToString());
                        this.Close();
                        break;

                    case "ReportMoveGoodsform":
                        CallBackMy.callbackEventHandlerReportMoveGoodsform(dgvFindT.Rows[irow].Cells[0].Value.ToString(), dgvFindT.Rows[irow].Cells[1].Value.ToString());
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void tsbtnadd_Click(object sender, EventArgs e)
        {
            // проверяем не запущена ли форма
            for (int x = 0; x < this.MdiParent.MdiChildren.Length; x++)
            {
                if (this.MdiParent.MdiChildren[x].Name == "Pform")
                {
                    this.MdiParent.MdiChildren[x].Focus();
                    return;
                }
            }
            // Запускаем форму если она не запущена
            Form Pform = new Pform();

            Pform.StartPosition = FormStartPosition.CenterScreen;
            Pform.WindowState   = FormWindowState.Maximized;
            //указываем владельца для формы
            Pform.MdiParent = this.MdiParent;  // где containerInstance - это экземпляр контейнера или указатель на MainForm
            Pform.Show();
            CallBackMy.callbackEventHandlerFormOpen(Pform);
        }
Ejemplo n.º 5
0
        private void ReportSalesAll()
        {
            dgvRepSales.Rows.Clear();
            dgvRepSales.Update();

            string periodN          = func.replace_date_sql(Convert.ToString(dtpSalesN.Value));
            string periodE          = func.replace_date_sql(Convert.ToString(dtpSalesE.Value.AddDays(1)));
            string QueryReportSales = "";
            string QueryDbase       = "";

            if (cmbGruptSales.Text != "")
            {
                QueryReportSales = "Select kod,rcena,count,zcena from Sales where date >'" + periodN + "' and date <'" + periodE + "' order by kod";
                QueryDbase       = "Select kod,name,(Select name from groupt where id= id_group) as groupt,quantity,zcena,rcena,(Select name from suppliers where id= id_suppliers) as sup from dbase where id_group=" + cmbGruptSales.SelectedValue + " order by kod";
            }
            else
            {
                QueryReportSales = "Select kod,rcena,count,zcena from Sales where date >'" + periodN + "' and date <'" + periodE + "' order by kod";
                QueryDbase       = "Select kod,name,(Select name from groupt where id= id_group) as groupt,quantity,zcena,rcena,(Select name from suppliers where id= id_suppliers) as sup from dbase order by kod";
            }
            DataTable ReportSalesTable = _SQl.ExecuteSQL(QueryReportSales);
            DataTable QueryDbaseTable  = _SQl.ExecuteSQL(QueryDbase);

            double coutnsrednee = 0;
            double summZsrednee = 0;
            double summRsrednee = 0;



            for (int l = 0; l < QueryDbaseTable.Rows.Count; l++)
            {
                string kod       = QueryDbaseTable.Rows[l][0].ToString();
                string namet     = QueryDbaseTable.Rows[l][1].ToString();
                string groupt    = QueryDbaseTable.Rows[l][2].ToString();
                double zcenanow  = Convert.ToDouble(QueryDbaseTable.Rows[l][4].ToString());
                double rcenanow  = Convert.ToDouble(QueryDbaseTable.Rows[l][5].ToString());
                double ostatok   = Convert.ToDouble(QueryDbaseTable.Rows[l][3].ToString());
                string suppliers = QueryDbaseTable.Rows[l][6].ToString();

                CallBackMy.callbackEventHandlerProgressBar(QueryDbaseTable.Rows.Count, l, namet);


                for (int irow = 0; irow < ReportSalesTable.Rows.Count; irow++)
                {
                    if (kod == ReportSalesTable.Rows[irow][0].ToString())
                    {
                        coutnsrednee = coutnsrednee + Convert.ToDouble(ReportSalesTable.Rows[irow][2].ToString());
                        summZsrednee = summZsrednee + (Convert.ToDouble(ReportSalesTable.Rows[irow][2].ToString()) * Convert.ToDouble(ReportSalesTable.Rows[irow][3].ToString()));
                        summRsrednee = summRsrednee + Math.Round((Convert.ToDouble(ReportSalesTable.Rows[irow][2].ToString()) * Convert.ToDouble(ReportSalesTable.Rows[irow][1].ToString())), 0);
                    }
                    if (irow == ReportSalesTable.Rows.Count - 1)
                    {
                        dgvRepSales.Rows.Add(kod, namet, zcenanow, rcenanow, coutnsrednee, ostatok, summZsrednee, Math.Round(summRsrednee, 0), Math.Round((((rcenanow / zcenanow) - 1) * 100), 2), groupt, Math.Round(summZsrednee / coutnsrednee, 2), Math.Round(summRsrednee / coutnsrednee, 2), Math.Round(((((Math.Round((summRsrednee / coutnsrednee), 2) / Math.Round((summZsrednee / coutnsrednee), 2)) - 1)) * 100), 2), suppliers);

                        coutnsrednee = 0;
                        summZsrednee = 0;
                        summRsrednee = 0;
                    }
                }
            }
            double itogZsumm = 0;
            double itogRsumm = 0;
            //double itogMargin = 0;
            double itogSRMargin = 0;
            double itogQty      = 0;

            for (int irowItog = 0; irowItog < dgvRepSales.Rows.Count; irowItog++)
            {
                itogQty   = itogQty + Convert.ToDouble(dgvRepSales.Rows[irowItog].Cells[4].Value);
                itogZsumm = itogZsumm + Convert.ToDouble(dgvRepSales.Rows[irowItog].Cells[6].Value);
                itogRsumm = itogRsumm + Convert.ToDouble(dgvRepSales.Rows[irowItog].Cells[7].Value);
                //itogMargin = itogMargin + Convert.ToDouble(dgvRepSales.Rows[irowItog].Cells[7].Value);
                itogSRMargin = itogSRMargin + Convert.ToDouble(dgvRepSales.Rows[irowItog].Cells[12].Value);

                if (irowItog == dgvRepSales.Rows.Count - 1)
                {
                    dgvRepSales.Rows.Add("", "", "", "Итоги", Math.Round(Convert.ToDouble(itogQty), 3), "", Math.Round(Convert.ToDouble(itogZsumm), 2), Math.Round(Convert.ToDouble(itogRsumm), 2), Math.Round((((itogRsumm / itogZsumm) - 1) * 100), 2), "", "", "", (itogSRMargin / dgvRepSales.Rows.Count));
                    return;
                }
                dgvRepSales.Rows[irowItog].Cells["Ostatok"].Style.BackColor = Color.LightYellow;
            }
        }