Beispiel #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            masterForm objFrmMain = new masterForm();

            this.Hide();
            objFrmMain.Show();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            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 Users Where Email='" + EmailTextBox.Text.Trim() + "' and password = '******'";
            SqlDataAdapter sda   = new SqlDataAdapter(query, sqlcon);



            using (SqlConnection connection = new SqlConnection(@"Data Source=celsa.database.windows.net;Initial Catalog=pos-mugdho;User ID=celsa;Password=Qwerty1@3$5"))
            {
                SqlCommand command = new SqlCommand(query, connection);
                connection.Open();

                SqlDataReader read = command.ExecuteReader();

                while (read.Read())
                {
                    Users.Name   = (read["Name"].ToString());
                    Users.Email  = (read["Email"].ToString());
                    Users.UserID = (read["UserID"].ToString());
                }
                read.Close();
            }

            DataTable dtbl = new DataTable();

            sda.Fill(dtbl);
            if (dtbl.Rows.Count == 1)
            {
                masterForm objFrmMain = new masterForm();
                this.Hide();
                objFrmMain.Show();
            }
            else
            {
                MessageBox.Show("Check your username and password");
            }
        }
        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!");
                }
            }
        }