Exemplo n.º 1
0
        private void btNextStatus_Click(object sender, EventArgs e)
        {
            if (config.statusCode.Equals("кнт") && !Convert.ToBoolean(dtData.DefaultView[dgvData.CurrentRow.Index]["isScan"].ToString()) && Convert.ToDecimal(dtData.DefaultView[dgvData.CurrentRow.Index]["sumEstimate"].ToString()) != 0)
            {
                MessageBox.Show("Для потверждения сметы\nтребуется прикрепить скан\nслужебной записки на деньги", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string comment;

            try
            {
                comment = dtData.DefaultView[dgvData.CurrentRow.Index]["Comment"].ToString();
            }
            catch
            {
                comment = "";
            }

            int statusEstimate = -1;

            if (dgvData.CurrentRow != null && dgvData.CurrentRow.Index != -1 && dtData != null && dtData.DefaultView.Count != 0)
            {
                statusEstimate = int.Parse(dtData.DefaultView[dgvData.CurrentRow.Index]["Status"].ToString());
            }
            dtTableStatus = readSQL.getTableStatusEstimat(statusEstimate, 1);
            if (dtTableStatus != null && dtTableStatus.Rows.Count > 0 && dtTableStatus.Rows[0]["nextStatus"] != DBNull.Value)
            {
                int id = int.Parse(dtData.DefaultView[dgvData.CurrentRow.Index]["id"].ToString());
                statusEstimate = int.Parse(dtTableStatus.Rows[0]["nextStatus"].ToString());
                string test = dtTableStatus.Rows[0]["nextStatus"].ToString();
                readSQL.changeStatusEstimate(id, statusEstimate, "");
                // Добавление комментария оператором
                if (config.statusCode.Equals("оп"))
                {
                    frmAddComment frmCom = new frmAddComment();
                    if (frmCom.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    comment += DateTime.Now + " Оператор : " + frmCom.comment;
                }

                if (statusEstimate == 2)
                {
                    readSQL.deleteChangeEstimateCheck(id);
                }

                readSQL.changeStatusEstimate(id, statusEstimate, comment);
                get_data();
            }
        }
Exemplo n.º 2
0
        private void btDown_Click(object sender, EventArgs e)
        {
            string comment;

            try
            {
                comment = dtData.DefaultView[dgvData.CurrentRow.Index]["Comment"].ToString();
            }
            catch
            {
                comment = "";
            }

            int statusEstimate = -1;

            if (dgvData.CurrentRow != null && dgvData.CurrentRow.Index != -1 && dtData != null && dtData.DefaultView.Count != 0)
            {
                statusEstimate = int.Parse(dtData.DefaultView[dgvData.CurrentRow.Index]["Status"].ToString());
            }
            dtTableStatus = readSQL.getTableStatusEstimat(statusEstimate, 1);
            if (dtTableStatus != null && dtTableStatus.Rows.Count > 0 && dtTableStatus.Rows[0]["undoStatus"] != DBNull.Value)
            {
                int id = int.Parse(dtData.DefaultView[dgvData.CurrentRow.Index]["id"].ToString());
                statusEstimate = int.Parse(dtTableStatus.Rows[0]["undoStatus"].ToString());
                if (config.statusCode.Equals("кнт") || config.statusCode.Equals("адм"))
                {
                    frmAddComment frmCom = new frmAddComment();
                    if (frmCom.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    comment += DateTime.Now + " Контролер: " + frmCom.comment;
                }
                readSQL.changeStatusEstimate(id, statusEstimate, comment);
                get_data();
            }
        }