private void button1_Click(object sender, EventArgs e)
        {
            DBManager manager=new DBManager();
            SqlConnection connection = manager.Connection();
            TempOrderGateway gateway=new TempOrderGateway();
            List<TempOrder> orders = gateway.GetempOrders();
            InvoiceUI invoice = new InvoiceUI(orders);
            invoice.ShowDialog();
            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 Temp_Order_Hold";
                SqlCommand command1 = new SqlCommand(deletequery, connection);
                connection.Open();
                command1.ExecuteNonQuery();
                string que = "DBCC CHECKIDENT (Temp_Order_Hold,Reseed,0)";
                command1=new SqlCommand(que,connection);
                command1.ExecuteNonQuery();
                string que1 = "set identity_insert Temp_Order_Hold on";
                command1=new SqlCommand(que1,connection);
                command1.ExecuteNonQuery();
                string insQuery = "insert into Order_Memo_Counter values(@date)";
                command1 = new SqlCommand(insQuery, connection);
                command1.Parameters.Clear();
                command1.Parameters.AddWithValue("@date", DateTime.Now.Date);
                command1.ExecuteNonQuery();
                memoNumver = GetLastMemoNumber();
                //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)
                {
                     invoice = new InvoiceUI(orders);
                    invoice.ShowDialog();
                    String deletequery = "delete from Temp_Order_Hold";
                    SqlCommand command1 = new SqlCommand(deletequery, connection);
                    connection.Open();
                    command1.ExecuteNonQuery();

                    string que = "DBCC CHECKIDENT (Temp_Order_Hold,Reseed,0)";
                    command1 = new SqlCommand(que, connection);
                    command1.ExecuteNonQuery();
                    string que1 = "set identity_insert Temp_Order_Hold on";
                    command1 = new SqlCommand(que1, connection);
                    command1.ExecuteNonQuery();
                    string insQuery = "insert into Order_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();
                }
            }



        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBManager        manager    = new DBManager();
            SqlConnection    connection = manager.Connection();
            TempOrderGateway gateway    = new TempOrderGateway();
            List <TempOrder> orders     = gateway.GetempOrders();
            InvoiceUI        invoice    = new InvoiceUI(orders);

            invoice.ShowDialog();
            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 Temp_Order_Hold";
                SqlCommand command1    = new SqlCommand(deletequery, connection);
                connection.Open();
                command1.ExecuteNonQuery();
                string que = "DBCC CHECKIDENT (Temp_Order_Hold,Reseed,0)";
                command1 = new SqlCommand(que, connection);
                command1.ExecuteNonQuery();
                string que1 = "set identity_insert Temp_Order_Hold on";
                command1 = new SqlCommand(que1, connection);
                command1.ExecuteNonQuery();
                string insQuery = "insert into Order_Memo_Counter values(@date)";
                command1 = new SqlCommand(insQuery, connection);
                command1.Parameters.Clear();
                command1.Parameters.AddWithValue("@date", DateTime.Now.Date);
                command1.ExecuteNonQuery();
                memoNumver = GetLastMemoNumber();
                //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)
                {
                    invoice = new InvoiceUI(orders);
                    invoice.ShowDialog();
                    String     deletequery = "delete from Temp_Order_Hold";
                    SqlCommand command1    = new SqlCommand(deletequery, connection);
                    connection.Open();
                    command1.ExecuteNonQuery();

                    string que = "DBCC CHECKIDENT (Temp_Order_Hold,Reseed,0)";
                    command1 = new SqlCommand(que, connection);
                    command1.ExecuteNonQuery();
                    string que1 = "set identity_insert Temp_Order_Hold on";
                    command1 = new SqlCommand(que1, connection);
                    command1.ExecuteNonQuery();
                    string insQuery = "insert into Order_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();
                }
            }
        }