Example #1
0
        private void MultipileCheck()
        {
            // newPeople = new People();
            newPeople.FirstName          = txtfname.Text;
            newPeople.Lasname            = txtlname.Text;
            newPeople.City               = txtcity.Text;
            newPeople.Tz                 = txtTZ.Text;
            newPeople.Details.DadName    = DadNametxtdadname.Text;
            newPeople.Details.MomName    = txtmomname.Text;
            newPeople.OpenDetailsForAdd  = radGeneral.Checked;
            newPeople.OpenForPersonalAdd = radPersonal.Checked;
            newPeople.Sexs               = radMale.Checked ? 1 : 2;
            if (newPeople.OpenDetailsForAdd)
            {
                newPeople.Temp = GLOBALVARS.MyUser.TempGeneral;
            }
            else
            {
                newPeople.Temp = GLOBALVARS.MyUser.TempPersonal;
            }
            SqlParameter[] prms = new SqlParameter[10];

            string sql = "";

            sql += "select p.ID, FirstName,lastname, ByUserName,RegDate " +
                   "from peoples p inner join peopledetails pd on p.ID = pd.relatedid inner join " +
                   "registerinfo r on pd.relatedid=r.relatedid where show <> 8 AND " +
                   BuildSql.GetSql(out prms[0], txtfname.Text, "FirstName", BuildSql.SqlKind.LIKE) +
                   BuildSql.GetSql(out prms[1], txtlname.Text, "Lastname", BuildSql.SqlKind.LIKE) +
                   BuildSql.GetSql(out prms[2], txtcity.Text, "City", BuildSql.SqlKind.LIKE) +
                   BuildSql.GetSql(out prms[4], DadNametxtdadname.Text, "DadName", BuildSql.SqlKind.LIKE) +
                   BuildSql.GetSql(out prms[5], txtmomname.Text, "MomName", BuildSql.SqlKind.LIKE) +
                   BuildSql.GetSql(out prms[6], txtTZ.Text, "Tz", BuildSql.SqlKind.LIKE);

            sql = BuildSql.CheckForLastAnd(ref sql);
            SqlDataReader reader = DBFunction.ExecuteReader(sql, prms);

            if (reader.HasRows)
            {
                reader.Read();
                string text = "כרטיס כבר קיים במערכת" + Environment.NewLine + "כרטיס על שם:" +
                              reader["FirstName"] + " " + reader["Lastname"] + ", נקלט בתאריך: "
                              + reader["RegDate"] + ", על ידי: " + reader["ByUserName"];
                MessageBox.Show(text, "כרטיס קיים", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                reader.Close();
                return;
            }
            OK = true;
            Close();
        }
        private void Search(object obj)
        {
            SqlDataReader reader;


            SqlParameter[] prms          = new SqlParameter[25];
            string         Sql           = "";
            string         AgeSql        = "";
            string         whoami        = "";
            string         whoiwant      = "";
            string         sqlwhoiwant   = "";
            string         sqlwhoami     = "";
            string         noteswhoami   = "";
            string         noteswhoiwant = "";
            string         LearnStatus   = "";
            string         Subscription  = "";
            string         sexs          = "";
            int            fromage       = (int)txtfromage.Value;
            int            tillage       = (int)txttillage.Value;
            string         show          = " AND SHOW <> 8 AND (show <2 or (show=5 and chadchan like '%{" + GLOBALVARS.MyUser.ID + "}%') or (show=4 and chadchan like '%{" + GLOBALVARS.MyUser.ID + "}%'))";
            string         IdFilter      = "";

            if (GLOBALVARS.MyUser.Control == User.TypeControl.Manger || GLOBALVARS.MyUser.Control == User.TypeControl.Admin)
            {
                show = " and show <> 8";
            }

            if (txtlearnstatus.SelectedIndex != -1)
            {
                LearnStatus = BuildSql.GetSql(out prms[16], txtlearnstatus.Text, "LearnStatus", BuildSql.SqlKind.EQUAL);
            }
            if (tillage > 0)
            {
                AgeSql = BuildSql.GetSql(out prms[0], fromage, "age", BuildSql.SqlKind.BETWEEN, true, tillage);
            }
            // if(chksubscription.Checked)
            // Subscription= BuildSql.GetSql(out prms[17], chksubscription.Checked, "Subscription", BuildSql.SqlKind.EQUAL,false);
            if (txtid.Value != 0)
            {
                IdFilter = " peoples.ID=" + txtid.Value + " AND ";
            }

            if (txtwhoami.Text.Length > 0)
            {
                noteswhoami = whoami = "(";
                foreach (string s in splitwords(txtwhoami.Text))
                {
                    if (s.Trim().Length > 0)
                    {
                        whoami      += " whoami like N'%" + s + "%' and";
                        noteswhoami += " notes like N'%" + s + "%' and";
                    }
                }
                whoami       = whoami.Remove(whoami.Length - 3, 3);
                noteswhoami  = noteswhoami.Remove(noteswhoami.Length - 3, 3);
                noteswhoami += ")";
                whoami      += ")";
                sqlwhoami    = "(" + whoami + " or " + noteswhoami + ")";
            }
            if (txtwhoiwant.Text.Length > 0)
            {
                whoiwant = noteswhoiwant = "(";
                foreach (string s in splitwords(txtwhoiwant.Text))
                {
                    if (s.Trim().Length > 0)
                    {
                        whoiwant      += " whoiwant like N'%" + s + "%' and";
                        noteswhoiwant += " notes like N'%" + s + "%' and";
                    }
                }
                whoiwant       = whoiwant.Remove(whoiwant.Length - 3, 3);
                noteswhoiwant  = noteswhoiwant.Remove(noteswhoiwant.Length - 3, 3);
                noteswhoiwant += ")";
                whoiwant      += ")";
                sqlwhoiwant    = "(" + whoiwant + " or " + noteswhoiwant + ")";
            }
            if (!string.IsNullOrEmpty(whoiwant) && !string.IsNullOrEmpty(whoami))
            {
                sqlwhoami += " and ";
            }
            if (txtsexs.SelectedIndex != -1)
            {
                sexs = BuildSql.GetSql(out prms[12], txtsexs.SelectedIndex + 1, "sexs", BuildSql.SqlKind.EQUAL);
            }

            Sql = " select schools,sexs,firstname,lastname,tall,age,City,fat," +
                  "FaceColor,Looks,WorkPlace,Beard,Zerem,Eda,LearnStatus,DadWork," +
                  "Background,Status,Tz,KindChasidut,HealthStatus,ZeremMom,Street," +
                  "DadName,MomName,MomWork,"
                  + "[peopledetails].[relatedid],[Peoples].[ID],Tel1,Tel2,Telephone,PhoneOfBachur from peoples inner join peopledetails on ID=relatedid  where temp='false' AND " +
                  BuildSql.GetSql(out prms[1], txtfname.Text, "FirstName", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[2], txtlname.Text, "Lastname", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[3], txtbeard.Text, "beard", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[4], txtbg.Text, "background", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[5], txtcoverhead.Text, "coverhead", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[6], txtdadwork.Text, "dadwork", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[7], txtfacecolor.Text, "facecolor", BuildSql.SqlKind.LIKE) +
                  IdFilter +
                  BuildSql.GetSql(out prms[8], txtfat.Text, "fat", BuildSql.SqlKind.LIKE) +
                  AgeSql +
                  BuildSql.GetSql(out prms[9], txtlooks.Text, "looks", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[10], txtpeticut.Text, "openhead", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[11], txtschool.Text, "schools", BuildSql.SqlKind.LIKE) +
                  sexs +
                  BuildSql.GetSql(out prms[13], txtzerem.Text, "(eda", BuildSql.SqlKind.LIKE, false, null, true) +
                  BuildSql.GetSql(out prms[14], txtzerem.Text, "zerem", BuildSql.SqlKind.LIKE, false, null, false, ") AND ") +
                  BuildSql.GetSql(out prms[15], txtstatus.Text, "Status", BuildSql.SqlKind.EQUAL) +
                  BuildSql.GetSql(out prms[17], txtCity.Text, "City", BuildSql.SqlKind.LIKE) +
                  BuildSql.GetSql(out prms[18], txtPhone.Text, "(Tel1", BuildSql.SqlKind.LIKE, false, null, true) +
                  BuildSql.GetSql(out prms[19], txtPhone.Text, "Tel2", BuildSql.SqlKind.LIKE, false, null, true) +
                  BuildSql.GetSql(out prms[20], txtPhone.Text, "Telephone", BuildSql.SqlKind.LIKE, false, null, true) +
                  BuildSql.GetSql(out prms[21], txtPhone.Text, "PhoneOfBachur", BuildSql.SqlKind.LIKE, false, null, false, " ) AND ") +
                  sqlwhoami + sqlwhoiwant +
                  LearnStatus +
                  Subscription;
            Sql    = BuildSql.CheckForLastAnd(ref Sql);
            Sql   += show;
            Sql   += " ORDER BY ID DESC";
            reader = DBFunction.ExecuteReader(Sql, prms);

            // fs.Search(txtfreeserach.Text, (FreeSearch.accuracy)cmb_accuracy.SelectedIndex);
            List <People> lst = new List <People>();


            while (reader.Read())
            {
                People p = new People();

                PeopleManipulations.ReaderToPeople(ref p, ref reader, PeopleManipulations.RtpFor.ForSearch);
                lst.Add(p);
            }


            olstpeople.BeginUpdate();
            olstpeople.SetObjects(lst);
            olstpeople.EndUpdate();

            reader.Close();
            DBFunction.CloseConnections();
            //picload.Visible = false;
            btnfilter.Enabled = true;
        }