Beispiel #1
0
        public List <RecordDue> GeDues()
        {
            List <RecordDue> dues = new List <RecordDue>();

            try
            {
                DBManager     manager    = new DBManager();
                SqlConnection connection = manager.Connection();
                string        selctQuery = "select * from DueRecords";
                SqlCommand    command    = new SqlCommand(selctQuery, connection);

                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    string    name   = reader[1].ToString();
                    string    mobile = reader[2].ToString();
                    RecordDue aDue   = new RecordDue();
                    aDue.Name   = name;
                    aDue.Mobile = mobile;
                    dues.Add(aDue);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(dues);
        }
Beispiel #2
0
        public void SaveDueRecord(RecordDue aRecordDue)
        {
            DBManager     manager = new DBManager();
            SqlCommand    cmdCommand;
            SqlConnection connection = manager.Connection();
            double        total;

            total = aRecordDue.Fbook + aRecordDue.Fcopy + aRecordDue.Fothers + aRecordDue.PreviousDue;
            connection.Open();
            try
            {
                if (HasThisCustomerPreviousDue(aRecordDue.Name, aRecordDue.Mobile) == false)
                {
                    string insertQuery =
                        "Insert into DueRecords values(@name,@mobile,@fbook,@fcopy,@others,@previousdue,@total,@pdate)";

                    cmdCommand = new SqlCommand(insertQuery, connection);

                    cmdCommand.Parameters.Clear();
                    cmdCommand.Parameters.Add("@name", aRecordDue.Name);
                    cmdCommand.Parameters.Add("@mobile", aRecordDue.Mobile);
                    //cmdCommand.Parameters.Add("@edition", aRecordDue.Fbook);
                    cmdCommand.Parameters.Add("@fbook", aRecordDue.Fbook);
                    cmdCommand.Parameters.Add("@fcopy", aRecordDue.Fcopy);
                    cmdCommand.Parameters.Add("@others", aRecordDue.Fothers);
                    cmdCommand.Parameters.AddWithValue("@previousdue", aRecordDue.PreviousDue);
                    cmdCommand.Parameters.Add("@total", total);
                    cmdCommand.Parameters.Add("@pdate", DateTime.Now.ToShortDateString());
                    int i = cmdCommand.ExecuteNonQuery();
                    MessageBox.Show(" Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string updateQuery =
                        "Update DueRecords Set F_Book=@fbook,F_Copy=@fcopy,F_Others=@others,Previous_Due=@previousdue,Total=@total,Date=@pdate where Name=@name and Mobile=@mobile";
                    cmdCommand = new SqlCommand(updateQuery, connection);
                    cmdCommand.Parameters.Clear();

                    //cmdCommand.Parameters.Add("@edition", aRecordDue.Fbook);
                    cmdCommand.Parameters.Add("@fbook", aRecordDue.Fbook);
                    cmdCommand.Parameters.Add("@fcopy", aRecordDue.Fcopy);
                    cmdCommand.Parameters.Add("@others", aRecordDue.Fothers);
                    cmdCommand.Parameters.AddWithValue("@previousdue", aRecordDue.PreviousDue);
                    cmdCommand.Parameters.Add("@total", total);
                    cmdCommand.Parameters.Add("@pdate", DateTime.Now.ToShortDateString());
                    cmdCommand.Parameters.Add("@name", aRecordDue.Name);
                    cmdCommand.Parameters.Add("@mobile", aRecordDue.Mobile);
                    //connection.Open();
                    int i = cmdCommand.ExecuteNonQuery();
                    MessageBox.Show("Updated", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void listView1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            try
            {
                int          index  = listView1.SelectedIndices[0];
                ListViewItem item   = listView1.Items[index];
                string       serial = item.Text;
                string       name   = item.SubItems[1].Text;
                string       mobile = item.SubItems[2].Text;

                string    a           = item.SubItems[3].Text;
                string    b           = item.SubItems[4].Text;
                string    c           = item.SubItems[5].Text;
                string    f           = item.SubItems[6].Text;
                double    fbook       = Convert.ToDouble(a);
                double    fcopy       = Convert.ToDouble(b);
                double    fothers     = Convert.ToDouble(c);
                double    previousDue = Convert.ToDouble(f);
                string    d           = item.SubItems[7].Text;
                double    total       = Convert.ToDouble(d);
                string    date        = item.SubItems[8].Text;
                RecordDue aDue        = new RecordDue();

                aDue.Serial      = serial;
                aDue.Name        = name;
                aDue.Mobile      = mobile;
                aDue.Fbook       = fbook;
                aDue.Fcopy       = fcopy;
                aDue.Fothers     = fothers;
                aDue.PreviousDue = previousDue;
                aDue.Total       = total;
                aDue.Date        = date;


                PaidUI       paid   = new PaidUI(aDue);
                DialogResult dialog = MessageBox.Show("Are you want to paid/add/Reduce now ?", "Message", MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question);
                if (dialog == DialogResult.Yes)
                {
                    listView1.Items.RemoveAt(index);
                    paid.ShowDialog();
                }
                else if (dialog == DialogResult.No)
                {
                    //this.Close();
                }

                return;
            }
            catch (Exception exception)
            {
                // MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        public void LoadAllBook()
        {
            try
            {
                DBManager     manager     = new DBManager();
                SqlConnection connection  = manager.Connection();
                string        selectQuery = "select * from DueRecords where Name LIKE '%" + searchTextBox.Text + "%'";
                SqlCommand    cmd         = new SqlCommand(selectQuery, connection);
                connection.Open();
                SqlDataReader    myReader = cmd.ExecuteReader();
                List <RecordDue> books    = new List <RecordDue>();
                while (myReader.Read())
                {
                    string serial   = myReader[0].ToString();
                    string name     = myReader[1].ToString();
                    string mobile   = myReader[2].ToString();
                    double fbook    = Convert.ToDouble(myReader[3]);
                    double fCopy    = Convert.ToDouble(myReader[4]);
                    double fothers  = Convert.ToDouble(myReader[5]);
                    double prveious = Convert.ToDouble(myReader[6]);


                    double    total = Convert.ToDouble(myReader[7]);
                    string    date  = myReader[8].ToString();
                    RecordDue aDue  = new RecordDue();



                    ListViewItem item = new ListViewItem(serial);
                    item.SubItems.Add(name);
                    item.SubItems.Add(mobile);
                    item.SubItems.Add(fbook.ToString());
                    item.SubItems.Add(fCopy.ToString());
                    item.SubItems.Add(fothers.ToString());
                    item.SubItems.Add(prveious.ToString());
                    item.SubItems.Add(total.ToString());
                    item.SubItems.Add(date);

                    item.Tag = aDue;
                    listView1.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (listView1.Items.Count <= 0)
            {
                MessageBox.Show("No data found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public PaidUI(RecordDue aRecord)
        {
            InitializeComponent();
            aDue = aRecord;


            serialtextBox.Text   = aDue.Serial;
            veiwNameTextBox.Text = aDue.Name;
            ViewMobile.Text      = aDue.Mobile;
            ViewBook.Text        = aDue.Fbook.ToString();
            viewPhotocopy.Text   = aDue.Fcopy.ToString();
            ViewOthers.Text      = aDue.Fothers.ToString();
            ViewTotal.Text       = aDue.Total.ToString();
            textBox1.Text        = aDue.Date;
        }
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int          index  = listView1.SelectedIndices[0];
                ListViewItem item   = listView1.Items[index];
                string       serial = item.Text;
                string       name   = item.SubItems[1].Text;
                string       mobile = item.SubItems[2].Text;

                string    a       = item.SubItems[3].Text;
                string    b       = item.SubItems[4].Text;
                string    c       = item.SubItems[5].Text;
                string    d       = item.SubItems[6].Text;
                double    fbook   = Convert.ToDouble(a);
                double    fcopy   = Convert.ToDouble(b);
                double    fothers = Convert.ToDouble(c);
                double    total   = Convert.ToDouble(d);
                string    date    = item.SubItems[7].Text;
                RecordDue aDue    = new RecordDue();

                aDue.Serial  = serial;
                aDue.Name    = name;
                aDue.Mobile  = mobile;
                aDue.Fbook   = fbook;
                aDue.Fcopy   = fcopy;
                aDue.Fothers = fothers;
                aDue.Total   = total;
                aDue.Date    = date;


                PaidUI paid = new PaidUI(aDue);
                listView1.Items.RemoveAt(index);
                paid.ShowDialog();
                return;
            }
            catch (Exception)
            {
                MessageBox.Show("Are you want to delivery the book?.", "?", MessageBoxButtons.OK,
                                MessageBoxIcon.Question);
            }
        }
Beispiel #7
0
        public void SaveDueRecord(RecordDue aRecordDue)
        {
            try
            {
                DBManager     manager    = new DBManager();
                SqlConnection connection = manager.Connection();
                double        total;

                total = aRecordDue.Fbook + aRecordDue.Fcopy + aRecordDue.Fothers;
                string     insertQuery = "INSERT INTO DueRecords values('" + aRecordDue.Name + "','" + aRecordDue.Mobile + "','" + aRecordDue.Fbook + "','" + aRecordDue.Fcopy + "','" + aRecordDue.Fothers + "','" + total + "','" + DateTime.Now.ToShortDateString() + "')";
                SqlCommand cmdCommand  = new SqlCommand(insertQuery, connection);
                connection.Open();
                int i = cmdCommand.ExecuteNonQuery();
                MessageBox.Show(" Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void saveButton_Click(object sender, EventArgs e)
 {
     try
     {
         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);
         RecordDueGateway gateway = new RecordDueGateway();
         gateway.SaveDueRecord(aRecordDue);
         listView1.Items.Clear();
         LoadAllBook();
         ClearALLTextbox();
     }
     catch (FormatException)
     {
         MessageBox.Show("Please fill every fields properly. ", "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
Beispiel #9
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);
            }
        }