Exemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string strDateNy = ServerTime.GetMonthlyString(Convert.ToDateTime(dgv_Main.CurrentRow.Cells["Date"].Value));

                string strNowNy = ServerTime.GetMonthlyString(ServerTime.Time);

                if (strDateNy != strNowNy)
                {
                    MessageDialog.ShowPromptMessage("不能跨月删除发票");
                    return;
                }

                if (MessageBox.Show("您是否确定要删除发票号为【" + dgv_Main.CurrentRow.Cells["InvoiceCode"].Value.ToString()
                                    + "】的发票?", "消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (m_findVoice.DeleteInvoiceInfo(dgv_Main.CurrentRow.Cells["InvoiceCode"].Value.ToString(), out m_err))
                    {
                        MessageBox.Show("删除成功!", "提示");
                    }
                    else
                    {
                        MessageBox.Show("删除失败 " + m_err, "提示");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            dgv_Main.DataSource = GetProviderName(m_findVoice.GetInvoiceInfo(dtp_Start.Value, dtp_End.Value));
            dgv_Mx.DataSource   = null;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!m_blFalg)
            {
                string strDateNy = ServerTime.GetMonthlyString(Convert.ToDateTime(m_dtInvoice.Rows[0]["Date"]));

                string strNowNy = ServerTime.GetMonthlyString(ServerTime.Time);

                if (strDateNy != strNowNy)
                {
                    MessageDialog.ShowPromptMessage("不能跨月重新保存发票");
                    return;
                }
            }

            m_dtInvoice = (DataTable)dgv_InvoiceShow.DataSource;

            foreach (DataRow drTemp in m_dtInvoice.Rows)
            {
                drTemp["UnitPrice"] = Convert.ToDecimal(drTemp["Price"]) / Convert.ToDecimal(drTemp["Count"]);
            }

            if (m_findInvoice.DeleteInvoiceInfo(m_strInvoice, out m_err))
            {
                if (m_findInvoice.AddInvoiceInfo(m_dtInvoice, out m_err))
                {
                    if (m_findInvoice.UpdatePrice(m_dtInvoice, out m_err))
                    {
                        MessageBox.Show("保存成功!", "提示");
                    }
                    else
                    {
                        MessageDialog.ShowErrorMessage(m_err);
                    }
                }
                else
                {
                    MessageDialog.ShowErrorMessage(m_err);
                }
            }
            else
            {
                MessageDialog.ShowErrorMessage(m_err);
            }
        }