Exemple #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            FeeCollection objFrmMain = new FeeCollection();

            this.Hide();
            objFrmMain.Show();
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int            isFeeOfMonthDuplicate = 0;
            SqlConnection  con = new SqlConnection(@"Data Source=celsa.database.windows.net;Initial Catalog=pos-mugdho;User ID=celsa;Password=Qwerty1@3$5");
            SqlCommand     cmd;
            SqlCommand     dmd;
            SqlDataAdapter adapt;

            string rollNo = StudentRollTextBox.Text;
            string name   = bunifuDropdown1.selectedValue + ',' + bunifuDropdown2.selectedValue;
            string trxID  = rollNo + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() +
                            DateTime.Today.Year.ToString();

            foreach (var item in items)
            {
                if (item.MonthName == bunifuDropdown1.selectedValue + ',' + bunifuDropdown2.selectedValue)
                {
                    isFeeOfMonthDuplicate = isFeeOfMonthDuplicate + 1;
                }
            }

            int month = DateTime.ParseExact(bunifuDropdown1.selectedValue, "MMMM", CultureInfo.CurrentCulture).Month;


            DateTime collectionMonth = new DateTime(Convert.ToInt32(bunifuDropdown2.selectedValue), month, 1);

            if (collectionMonth < creationDate.Date)
            {
                MessageBox.Show("Fees for the month information is wrong");
            }
            else if (isFeeOfMonthDuplicate > 0)
            {
                MessageBox.Show("A transaction for selected month for this student is already exists");
            }
            else
            {
                dmd = new SqlCommand(@"update StudentDue set TotalDue= @TotalDue where RollNumber=@StudentRollNumber", con);
                cmd = new SqlCommand("insert into MoneyCollection(StudentRollNumber,CollectedAmount,CollectorID,CollectionMonth,StudentName,CollectionDate,CollectionType,OtherDiscount,TrxID) values(@StudentRollNumber,@CollectedAmount,@CollectorID,@CollectionMonth,@StudentName,@CollectionDate,@CollectionType,@OtherDiscount,@TrxID)", con);
                con.Open();
                int totalDue;
                if (int.TryParse(TotalDue.Text, out totalDue))
                {
                    dmd.Parameters.AddWithValue("@TotalDue", totalDue);
                }

                int rollNumber;
                if (int.TryParse(StudentRollTextBox.Text, out rollNumber))
                {
                    cmd.Parameters.AddWithValue("@StudentRollNumber", rollNumber);
                    dmd.Parameters.AddWithValue("@StudentRollNumber", rollNumber);
                }
                cmd.Parameters.AddWithValue("@CollectedAmount", AmountTextBox.Text);
                cmd.Parameters.AddWithValue("@StudentName", StudentNameTextBox.Text);
                cmd.Parameters.AddWithValue("@CollectionMonth", bunifuDropdown1.selectedValue + ',' + bunifuDropdown2.selectedValue);
                cmd.Parameters.AddWithValue("@CollectorID", Users.UserID);
                cmd.Parameters.AddWithValue("@CollectionDate", DateTime.Today);
                cmd.Parameters.AddWithValue("@OtherDiscount", OtherDiscountTextBox.Text);
                cmd.Parameters.AddWithValue("@CollectionType", "MonthlyFee");
                cmd.Parameters.AddWithValue("@TrxID", trxID);

                cmd.ExecuteNonQuery();
                dmd.ExecuteNonQuery();
                con.Close();
                SendSMS(StudentRollTextBox.Text, AmountTextBox.Text, trxID, StudentNameTextBox.Text);
                MessageBox.Show("Record Inserted Successfully");



                FeeCollection NewForm = new FeeCollection();
                NewForm.Show();
                this.Dispose(false);

                string        collectionType = "MonthlyFee";
                PrintableForm objFrmMain     = new PrintableForm(rollNo, name, collectionType);
                objFrmMain.Show();
            }
        }