示例#1
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            try
            {
                DBManager     manager6     = new DBManager();
                SqlConnection connection6  = manager6.Connection();
                string        selectQuery6 = "insert into  Due_Collection values(@pay,@empty,@payCollection,@date)";
                SqlCommand    cmd6         = new SqlCommand(selectQuery6, connection6);
                connection6.Open()
                ;
                cmd6.Parameters.Clear();
                cmd6.Parameters.Add("@pay", "0");
                cmd6.Parameters.Add("@empty", totalDuetextBox.Text);
                cmd6.Parameters.AddWithValue("@payCollection", "0");
                cmd6.Parameters.Add("@date", DateTime.Now.ToShortDateString());


                cmd6.ExecuteNonQuery();

                connection6.Close();


                RecordDue aRecordDue = new RecordDue();
                aRecordDue.Name        = cnameTextBox.Text;
                aRecordDue.Mobile      = cMobileTextBox.Text;
                aRecordDue.Fbook       = Convert.ToDouble(forBooktextBox.Text);
                aRecordDue.Fcopy       = Convert.ToDouble(forphotocopytextBox.Text);
                aRecordDue.Fothers     = Convert.ToDouble(forOThersTextBox.Text);
                aRecordDue.PreviousDue = Convert.ToDouble(previousDueTextBox.Text);
                RecordDueGateway gateway = new RecordDueGateway();
                gateway.SaveDueRecord(aRecordDue);

                listView1.Items.Clear();
                LoadAllBook();


                GetAllDueRecord();
                TempDueRecord aRecord = new TempDueRecord();
                aRecord.CoustemerName = cnameTextBox.Text;
                aRecord.Mobile        = cMobileTextBox.Text;
                aRecord.ForBook       = Convert.ToDouble(forBooktextBox.Text);
                aRecord.ForCopy       = Convert.ToDouble(forphotocopytextBox.Text);
                aRecord.ForOthers     = Convert.ToDouble(forOThersTextBox.Text);
                aRecord.Total         = Convert.ToDouble(totalDuetextBox.Text);
                if (previousDueTextBox.Text.Equals("") || previousDueTextBox.Text.Equals("0"))
                {
                    aRecord.PreviousDue = 0;
                }
                else
                {
                    aRecord.PreviousDue = Convert.ToDouble(previousDueTextBox.Text
                                                           );
                }
                aRecord.MemoNumber = memoNumver;
                TempDueRecordGateway DueRecordGateway = new TempDueRecordGateway();
                DueRecordGateway.SaveTempDueRecord(aRecord);


                //DueReportUI dueReportUi=new DueReportUI(cnameTextBox.Text,cMobileTextBox.Text,forBooktextBox.Text,forphotocopytextBox.Text,forOThersTextBox.Text,totalDuetextBox.Text);
                //dueReportUi.ShowDialog();

                //listView1.Items.Clear();
                //LoadAllBook();
                //ClearALLTextbox();
            }
            catch (NullReferenceException exception)
            {
                MessageBox.Show("Please fill every fields properly. ", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            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);
            }
        }