コード例 #1
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();
            }
        }
コード例 #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            int paidAmountDuringAddmissionForCheck;

            int.TryParse(PaidAmountTextbox.Text, out paidAmountDuringAddmissionForCheck);

            int addmissionFeeForCheck;

            int.TryParse(AdmissionFeeDropdown.selectedValue, out addmissionFeeForCheck);

            int rollNumberForDuplicacy;

            int.TryParse(RollNumberTextBox.Text, out rollNumberForDuplicacy);
            SqlConnection sqlcon = new SqlConnection(@"Data Source=celsa.database.windows.net;Initial Catalog=pos-mugdho;User ID=celsa;Password=Qwerty1@3$5");

            string query = "Select * from Registration Where StudentRollNumber=" + rollNumberForDuplicacy;

            SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);

            DataTable dtbl = new DataTable();

            sda.Fill(dtbl);
            if (dtbl.Rows.Count == 1)
            {
                MessageBox.Show("This RollNumber is duplicate");
            }
            else if (addmissionFeeForCheck > paidAmountDuringAddmissionForCheck)
            {
                MessageBox.Show("You have to pay full admission fee for Registration");
            }
            else
            {
                //if(AdmissionFeeDropdown.selectedValue<TotalPaybleTextbox.Text)
                if (RollNumberTextBox.Text != "" && studentNameTextBox.Text != "")
                {
                    cmd = new SqlCommand("insert into Registration(StudentName,StudentRollNumber," +
                                         "GuardiansName,Address,DoB,School,Class,AdmissionFee," +
                                         "MobileNumber,Version,Course,MonthlyFee,CourseStartDate,Status," +
                                         "CreationDate,CreatedBy,RefrenceRollNumber," +
                                         "Discount,TotalPayableDuringAdmission," +
                                         "PaidAmountDuringAdmission) " +
                                         "values(@StudentName," +
                                         "@StudentRollNumber,@GuardiansName,@Address,@DoB,@School," +
                                         "@Class,@AdmissionFee,@MobileNumber,@Version" +
                                         ",@Course,@MonthlyFee,@CourseStartDate,@Status,@CreationDate," +
                                         "@CreatedBy,@RefrenceRollNumber,@Discount," +
                                         "@TotalPayableDuringAdmission,@PaidAmountDuringAdmission)", con);

                    dmd = new SqlCommand(@"insert into StudentDue(RollNumber,TotalDue) values (@RollNumber,@TotalDue)", con);
                    fmd = new SqlCommand(@"insert into Reference(ReferenceRollNumber,ReferedFor,DiscountAmount) values (@ReferenceRollNumber,@ReferedFor,@DiscountAmount)", con);
                    gmd = 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);

                    pmd = 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();
                    cmd.Parameters.AddWithValue("@StudentName", studentNameTextBox.Text);

                    int rollNumber;
                    if (int.TryParse(RollNumberTextBox.Text, out rollNumber))
                    {
                        cmd.Parameters.AddWithValue("@StudentRollNumber", rollNumber);
                        fmd.Parameters.AddWithValue("@ReferedFor", rollNumber);
                        dmd.Parameters.AddWithValue("@RollNumber", rollNumber);

                        int due;
                        int.TryParse(DueTextbox.Text, out due);
                        dmd.Parameters.AddWithValue("@TotalDue", due);
                        cmd.Parameters.AddWithValue("@Discount", due);
                        fmd.Parameters.AddWithValue("@DiscountAmount", 500);
                    }

                    int totalpayableDuringAddmission;
                    int.TryParse(TotalPaybleTextbox.Text, out totalpayableDuringAddmission);

                    int paidAmountDuringAddmission;
                    int.TryParse(PaidAmountTextbox.Text, out paidAmountDuringAddmission);

                    int addmissionFee;
                    int.TryParse(AdmissionFeeDropdown.selectedValue, out addmissionFee);
                    int monthlyPayable = paidAmountDuringAddmission - addmissionFee;

                    cmd.Parameters.AddWithValue("@GuardiansName", GuardiansNameTextbox.Text);
                    cmd.Parameters.AddWithValue("@Address", AddressTexbox.Text);
                    cmd.Parameters.AddWithValue("@DoB", bunifuDatepicker2.Value);
                    cmd.Parameters.AddWithValue("@School", bunifuDropdown1.selectedValue);
                    cmd.Parameters.AddWithValue("@Class", bunifuDropdown3.selectedValue);
                    cmd.Parameters.AddWithValue("@AdmissionFee", AdmissionFeeDropdown.selectedValue);
                    cmd.Parameters.AddWithValue("@MobileNumber", MobileTextBox.Text);
                    cmd.Parameters.AddWithValue("@Version", bunifuDropdown2.selectedValue);
                    cmd.Parameters.AddWithValue("@Course", bunifuDropdown4.selectedValue);
                    cmd.Parameters.AddWithValue("@MonthlyFee", monthlyFeeDropDown.selectedValue);
                    cmd.Parameters.AddWithValue("@CourseStartDate", bunifuDatepicker3.Value);
                    cmd.Parameters.AddWithValue("@Status", bunifuDropdown7.selectedValue);
                    cmd.Parameters.AddWithValue("@CreationDate", DateTime.Today);
                    cmd.Parameters.AddWithValue("@CreatedBy", Users.UserID);
                    cmd.Parameters.AddWithValue("@TotalPayableDuringAdmission", totalpayableDuringAddmission);
                    cmd.Parameters.AddWithValue("@PaidAmountDuringAdmission", paidAmountDuringAddmission);

                    int referenceRollNumber;
                    if (int.TryParse(ReferenceRollTextBox.Text, out referenceRollNumber))
                    {
                        cmd.Parameters.AddWithValue("@RefrenceRollNumber", referenceRollNumber);
                        fmd.Parameters.AddWithValue("@ReferenceRollNumber", referenceRollNumber);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@RefrenceRollNumber", referenceRollNumber);
                        fmd.Parameters.AddWithValue("@ReferenceRollNumber", referenceRollNumber);
                    }

                    string trxID = RollNumberTextBox.Text + DateTime.Today.Day.ToString() + DateTime.Today.Month.ToString() +
                                   DateTime.Today.Year.ToString();

                    gmd.Parameters.AddWithValue("@StudentRollNumber", rollNumber);
                    gmd.Parameters.AddWithValue("@CollectedAmount", AdmissionFeeDropdown.selectedValue.ToString());
                    gmd.Parameters.AddWithValue("@StudentName", studentNameTextBox.Text);
                    string monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(bunifuDatepicker3.Value.Month);
                    gmd.Parameters.AddWithValue("@CollectionMonth", monthName + "," + bunifuDatepicker3.Value.Year.ToString());
                    gmd.Parameters.AddWithValue("@CollectorID", Users.UserID);
                    gmd.Parameters.AddWithValue("@CollectionDate", DateTime.Today);
                    gmd.Parameters.AddWithValue("@CollectionType", "Admission");
                    gmd.Parameters.AddWithValue("@OtherDiscount", DiscountTextbox.Text);
                    gmd.Parameters.AddWithValue("@TrxID", trxID);



                    pmd.Parameters.AddWithValue("@StudentRollNumber", rollNumber);
                    pmd.Parameters.AddWithValue("@CollectedAmount", monthlyPayable.ToString());
                    pmd.Parameters.AddWithValue("@StudentName", studentNameTextBox.Text);
                    //  string monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(bunifuDatepicker3.Value.Month);
                    pmd.Parameters.AddWithValue("@CollectionMonth", monthName + "," + bunifuDatepicker3.Value.Year.ToString());
                    pmd.Parameters.AddWithValue("@CollectorID", Users.UserID);
                    pmd.Parameters.AddWithValue("@CollectionDate", DateTime.Today);
                    pmd.Parameters.AddWithValue("@CollectionType", "MonthlyFee");
                    pmd.Parameters.AddWithValue("@OtherDiscount", DiscountTextbox.Text);
                    pmd.Parameters.AddWithValue("@TrxID", trxID);



                    cmd.ExecuteNonQuery();
                    dmd.ExecuteNonQuery();
                    fmd.ExecuteNonQuery();
                    gmd.ExecuteNonQuery();
                    pmd.ExecuteNonQuery();

                    con.Close();
                    MessageBox.Show("Record Inserted Successfully");

                    SendSMS(RollNumberTextBox.Text, paidAmountDuringAddmission.ToString(), trxID, MobileTextBox.Text, studentNameTextBox.Text);
                    masterForm NewForm = new masterForm();
                    NewForm.Show();
                    this.Dispose(false);
                    string        collectionType = "AdmissionFee";
                    string        date           = monthName + "," + bunifuDatepicker3.Value.Year.ToString();
                    PrintableForm objFrmMain     = new PrintableForm(rollNumber.ToString(), date, collectionType);
                    objFrmMain.Show();
                }
                else
                {
                    MessageBox.Show("Please Provide Required Fields!");
                }
            }
        }