private void printDueRecordButton(object sender, EventArgs e)
        {
            DBManager manager=new DBManager();
            SqlConnection connection = manager.Connection();


            TempDueRecordGateway gateway = new TempDueRecordGateway();
           
            List<TempDueRecord> aList = gateway.GeTempDueRecords();
            try
            {
                
                DueReportUI dueReport = new DueReportUI(aList);
                dueReport.ShowDialog();
                //temp due record 
                System.Windows.Forms.DialogResult dialog = MessageBox.Show("Did you print the document?", "Print Message",
                 MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialog == DialogResult.Yes)
                {
                    String deletequery = "delete from TempDueRecord";
                    SqlCommand command1 = new SqlCommand(deletequery, connection);
                    connection.Open();
                    command1.ExecuteNonQuery();
                    string que = "DBCC CHECKIDENT (TempDueRecord,Reseed,0)";
                    command1 = new SqlCommand(que, connection);
                    command1.ExecuteNonQuery();
                    string que1 = "set identity_insert TempDueRecord on";
                    command1 = new SqlCommand(que1, connection);
                    command1.ExecuteNonQuery();
                    string insQuery = "insert into Due_Memo_Counter values(@date)";
                    command1 = new SqlCommand(insQuery, connection);
                    command1.Parameters.Clear();
                    command1.Parameters.AddWithValue("@date", DateTime.Now.Date);
                    command1.ExecuteNonQuery();
                    memoNumver = GetLastMemoNumber();

                }
                else if (dialog == DialogResult.No)
                {
                    System.Windows.Forms.DialogResult dialog1 = MessageBox.Show("Are you want to print now?",
                        "Print Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialog1 == DialogResult.Yes)
                    {
                       dueReport = new DueReportUI(aList);
                        dueReport.ShowDialog();
                        String deletequery = "delete from TempDueRecord";
                        SqlCommand command1 = new SqlCommand(deletequery, connection);
                        connection.Open();
                        command1.ExecuteNonQuery();

                        string que = "DBCC CHECKIDENT (TempDueRecord,Reseed,0)";
                        command1 = new SqlCommand(que, connection);
                        command1.ExecuteNonQuery();
                        string que1 = "set identity_insert TempDueRecord on";
                        command1 = new SqlCommand(que1, connection);
                        command1.ExecuteNonQuery();
                        string insQuery = "insert into Due_Memo_Counter values(@date)";
                        command1 = new SqlCommand(insQuery, connection);
                        command1.Parameters.Clear();
                        command1.Parameters.AddWithValue("@date", DateTime.Now.Date);
                        command1.ExecuteNonQuery();
                        memoNumver = GetLastMemoNumber();


                        DialogResult d2 = MessageBox.Show(" Print Sucessful! Are you want ot exit? ", "Print Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (d2 == DialogResult.Yes)
                        {
                            this.Close();
                        }
                        else if (d2 == DialogResult.No)
                        {
                            //OrderUI odUi=new OrderUI();
                            //odUi.ShowDialog();
                        }
                    }
                    else if (dialog1 == DialogResult.No)
                    {
                        //this.Close();
                    }
                }
                
                    //end 
                
            }
            catch (Exception exception)
            {

                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void printDueRecordButton(object sender, EventArgs e)
        {
            DBManager     manager    = new DBManager();
            SqlConnection connection = manager.Connection();


            TempDueRecordGateway gateway = new TempDueRecordGateway();

            List <TempDueRecord> aList = gateway.GeTempDueRecords();

            try
            {
                DueReportUI dueReport = new DueReportUI(aList);
                dueReport.ShowDialog();
                //temp due record
                System.Windows.Forms.DialogResult dialog = MessageBox.Show("Did you print the document?", "Print Message",
                                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialog == DialogResult.Yes)
                {
                    String     deletequery = "delete from TempDueRecord";
                    SqlCommand command1    = new SqlCommand(deletequery, connection);
                    connection.Open();
                    command1.ExecuteNonQuery();
                    string que = "DBCC CHECKIDENT (TempDueRecord,Reseed,0)";
                    command1 = new SqlCommand(que, connection);
                    command1.ExecuteNonQuery();
                    string que1 = "set identity_insert TempDueRecord on";
                    command1 = new SqlCommand(que1, connection);
                    command1.ExecuteNonQuery();
                    string insQuery = "insert into Due_Memo_Counter values(@date)";
                    command1 = new SqlCommand(insQuery, connection);
                    command1.Parameters.Clear();
                    command1.Parameters.AddWithValue("@date", DateTime.Now.Date);
                    command1.ExecuteNonQuery();
                    memoNumver = GetLastMemoNumber();
                }
                else if (dialog == DialogResult.No)
                {
                    System.Windows.Forms.DialogResult dialog1 = MessageBox.Show("Are you want to print now?",
                                                                                "Print Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialog1 == DialogResult.Yes)
                    {
                        dueReport = new DueReportUI(aList);
                        dueReport.ShowDialog();
                        String     deletequery = "delete from TempDueRecord";
                        SqlCommand command1    = new SqlCommand(deletequery, connection);
                        connection.Open();
                        command1.ExecuteNonQuery();

                        string que = "DBCC CHECKIDENT (TempDueRecord,Reseed,0)";
                        command1 = new SqlCommand(que, connection);
                        command1.ExecuteNonQuery();
                        string que1 = "set identity_insert TempDueRecord on";
                        command1 = new SqlCommand(que1, connection);
                        command1.ExecuteNonQuery();
                        string insQuery = "insert into Due_Memo_Counter values(@date)";
                        command1 = new SqlCommand(insQuery, connection);
                        command1.Parameters.Clear();
                        command1.Parameters.AddWithValue("@date", DateTime.Now.Date);
                        command1.ExecuteNonQuery();
                        memoNumver = GetLastMemoNumber();


                        DialogResult d2 = MessageBox.Show(" Print Sucessful! Are you want ot exit? ", "Print Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (d2 == DialogResult.Yes)
                        {
                            this.Close();
                        }
                        else if (d2 == DialogResult.No)
                        {
                            //OrderUI odUi=new OrderUI();
                            //odUi.ShowDialog();
                        }
                    }
                    else if (dialog1 == DialogResult.No)
                    {
                        //this.Close();
                    }
                }

                //end
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }