Ejemplo n.º 1
0
        private void dgvDolgi_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var grid = sender as DataGridView;

            if (grid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                tbxFilter.Focus();

                DataSetTpos.debtRow debRow = DBclass.DS.debt.NewdebtRow();
                debRow.expenseId = Convert.ToInt32(grid.Rows[e.RowIndex].Cells["expenseId"].Value);
                debRow.payDate   = DateTime.Now;
                debRow.terminal  = 0;

                //debRow.
                DataRow[] drs = DBclass.DS.expense.Select("expenseId = " + grid.Rows[e.RowIndex].Cells["expenseId"].Value.ToString());
                if (drs.Length != 0)
                {
                    drs[0]["terminal"] = Convert.ToInt32(grid.Rows[e.RowIndex].Cells["terminal"].Value);
                    drs[0]["status"]   = 0;
                }
                DBclass.DS.debt.AdddebtRow(debRow);

                DataSetTposTableAdapters.debtTableAdapter daDebt = new DataSetTposTableAdapters.debtTableAdapter();
                daDebt.Update(debRow);
                DataSetTposTableAdapters.expenseTableAdapter daExp = new DataSetTposTableAdapters.expenseTableAdapter();
                daExp.Update(drs);
                //dgvDolgi.Refresh();
            }
            //else
            //if (e.RowIndex >= 0)
            //{
            //    dgvDolgi.CurrentCell = dgvDolgi.Rows[e.RowIndex].Cells["terminal"];
            //    dgvDolgi.BeginEdit(true);
            //}
        }
Ejemplo n.º 2
0
        private void dgvDolgi_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var grid = sender as DataGridView;

            if (grid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                int sums = Convert.ToInt32(grid.Rows[e.RowIndex].Cells["sums"].Value);

                DataSetTpos.debtRow debRow = DBclass.DS.debt.NewdebtRow();
                DataSetTposTableAdapters.infoTableAdapter daInfo = new DataSetTposTableAdapters.infoTableAdapter();
                daInfo.Fill(DBclass.DS.info);
                string    dat    = DateTime.Now.ToString("dd.mm.yyyy");
                DataRow[] drInfo = DBclass.DS.info.Select("Dates='" + Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00") + "'");
                debRow.payDate = DateTime.Now;
                debtPaid dbt = new debtPaid(sums);
                if (dbt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    int termi = 0;
                    if (dbt.terminal == true)
                    {
                        termi = dbt.paidSumm;
                        drInfo[0]["terminal"] = Convert.ToInt32(drInfo[0]["terminal"]) + termi;
                    }
                    else
                    {
                        drInfo[0]["nal"] = Convert.ToInt32(drInfo[0]["nal"]) + Convert.ToInt32(dbt.paidSumm);
                    }
                    debRow.terminal      = termi;
                    drInfo[0]["proceed"] = Convert.ToInt32(drInfo[0]["proceed"]) + Convert.ToInt32(dbt.paidSumm);
                    debRow.summ          = Convert.ToInt32(dbt.paidSumm);
                }

                //debRow.
                DataRow[] drs = DBclass.DS.contragent.Select("contragentId = " + grid.Rows[e.RowIndex].Cells["contragentId"].Value.ToString());
                if (drs.Length != 0)
                {
                    drs[0]["sums"] = Convert.ToInt32(drs[0]["sums"]) - debRow.summ;
                }
                DBclass.DS.debt.AdddebtRow(debRow);
                daInfo.Update(drInfo[0]);
                DataSetTposTableAdapters.debtTableAdapter daDebt = new DataSetTposTableAdapters.debtTableAdapter();
                daDebt.Update(debRow);
                DataSetTposTableAdapters.contragentTableAdapter daContr = new DataSetTposTableAdapters.contragentTableAdapter();
                daContr.Update(drs);
                contragentTableAdapter1.Fill(DBclass.DS.contragent);
                DataView dv = new DataView(DBclass.DS.contragent);
                dv.RowFilter        = "sums<>0";
                dgvDolgi.DataSource = dv;
                //dgvDolgi.Refresh();
            }
            //else
            //if (e.RowIndex >= 0)
            //{
            //    dgvDolgi.CurrentCell = dgvDolgi.Rows[e.RowIndex].Cells["terminal"];
            //    dgvDolgi.BeginEdit(true);
            //}
        }