Exemple #1
0
        private void setButton_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(this.connection);

            con.Open();
            SqlCommand cmdmember = new SqlCommand("select count(*) from member where id = @id and id = supporter_id;", con);

            cmdmember.Parameters.AddWithValue("@id", ExtensionFunction.PersianToEnglish(idTextbox.Text));
            int c = 0;

            using (SqlDataReader reader = cmdmember.ExecuteReader())
            {
                if (reader.Read())
                {
                    c = reader.GetInt32(0);
                }
            }
            if (c != 0)
            {
                var newform = new newReqForm2(ExtensionFunction.PersianToEnglish(idTextbox.Text), "member");
                newform.ShowDialog(this);
            }
            else
            {
                SqlCommand cmdapplicant = new SqlCommand("select count(*) from otherApplicant where id = @id;", con);
                cmdapplicant.Parameters.AddWithValue("@id", ExtensionFunction.PersianToEnglish(idTextbox.Text));
                c = 0;
                using (SqlDataReader reader = cmdapplicant.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        c = reader.GetInt32(0);
                    }
                }
                if (c != 0)
                {
                    var newform = new newReqForm2(ExtensionFunction.PersianToEnglish(idTextbox.Text), "applicant");
                    newform.ShowDialog(this);
                }
                else
                {
                    FMessegeBox.FarsiMessegeBox.Show("شماره ملی عضو موجود نیست!", "خطا!", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Error, FMessegeBox.FMessegeBoxDefaultButton.button1);
                }
            }
            con.Close();
        }
        private void setButton_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(this.connection);

            con.Open();
            SqlCommand cmdcheck;

            if (this.Text == "بررسی تقاضا" || this.Text == "ویرایش تقاضا")
            {
                cmdcheck = new SqlCommand("select count(*) from request where applicantId = sup and id = @id and result is Null;", con);
                cmdcheck.Parameters.AddWithValue("@id", ExtensionFunction.PersianToEnglish(idTextbox.Text));
                int c = 0;
                using (SqlDataReader reader = cmdcheck.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        c = reader.GetInt32(0);
                    }
                }
                if (c != 0)
                {
                    if (this.Text == "بررسی تقاضا")
                    {
                        var newform = new checkReqForm(ExtensionFunction.PersianToEnglish(idTextbox.Text), "check");
                        newform.ShowDialog(this);
                    }
                    else
                    {
                        var newform = new newReqForm2(ExtensionFunction.PersianToEnglish(idTextbox.Text), "edit");
                        newform.ShowDialog(this);
                    }
                }
                else
                {
                    FMessegeBox.FarsiMessegeBox.Show("شماره تقاضا موجود نیست!", "خطا!", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Error, FMessegeBox.FMessegeBoxDefaultButton.button1);
                }
            }
            else if (this.Text == "ثبت ارائه معرفی‌نامه" || this.Text == "ویرایش بررسی")
            {
                if (this.Text == "ویرایش بررسی")
                {
                    cmdcheck = new SqlCommand("select count(*) from request where applicantId = sup and id = @id and result is not Null and deliveryDate is Null;", con);
                }
                else
                {
                    cmdcheck = new SqlCommand("select count(*) from request where applicantId = sup and id = @id and result = N'تایید' and deliveryDate is Null;", con);
                }
                cmdcheck.Parameters.AddWithValue("@id", ExtensionFunction.PersianToEnglish(idTextbox.Text));
                int c = 0;
                using (SqlDataReader reader = cmdcheck.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        c = reader.GetInt32(0);
                    }
                }
                if (c != 0)
                {
                    if (this.Text == "ثبت ارائه معرفی‌نامه")
                    {
                        var newform = new responseReqForm(ExtensionFunction.PersianToEnglish(idTextbox.Text), "response");
                        newform.ShowDialog(this);
                    }
                    else
                    {
                        var newform = new checkReqForm(ExtensionFunction.PersianToEnglish(idTextbox.Text), "edit");
                        newform.ShowDialog(this);
                    }
                }
                else
                {
                    FMessegeBox.FarsiMessegeBox.Show("شماره تقاضا موجود نیست!", "خطا!", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Error, FMessegeBox.FMessegeBoxDefaultButton.button1);
                }
            }
            else if (this.Text == "ویرایش مصوبه")
            {
                cmdcheck = new SqlCommand("select count(*) from enactment where id = @id;", con);
                cmdcheck.Parameters.AddWithValue("@id", ExtensionFunction.PersianToEnglish(idTextbox.Text));
                int c = 0;
                using (SqlDataReader reader = cmdcheck.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        c = reader.GetInt32(0);
                    }
                }
                if (c != 0)
                {
                    var newform = new editEnactmentForm(ExtensionFunction.PersianToEnglish(idTextbox.Text));
                    newform.ShowDialog(this);
                }
                else
                {
                    FMessegeBox.FarsiMessegeBox.Show("شماره مصوبه موجود نیست!", "خطا!", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Error, FMessegeBox.FMessegeBoxDefaultButton.button1);
                }
            }
            else
            {
                cmdcheck = new SqlCommand("select count(*) from request where applicantId = sup and id = @id and deliveryDate is not Null;", con);
                cmdcheck.Parameters.AddWithValue("@id", ExtensionFunction.PersianToEnglish(idTextbox.Text));
                int c = 0;
                using (SqlDataReader reader = cmdcheck.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        c = reader.GetInt32(0);
                    }
                }
                if (c != 0)
                {
                    var newform = new responseReqForm(ExtensionFunction.PersianToEnglish(idTextbox.Text), "edit");
                    newform.ShowDialog(this);
                }
                else
                {
                    FMessegeBox.FarsiMessegeBox.Show("شماره تقاضا موجود نیست!", "خطا!", FMessegeBox.FMessegeBoxButtons.Ok, FMessegeBox.FMessegeBoxIcons.Error, FMessegeBox.FMessegeBoxDefaultButton.button1);
                }
            }
            con.Close();
        }