Esempio n. 1
0
        public bool LoadData(bool reset = false)
        {
            ListNameColumnPeople = new List <KeyValueClass>();
            ListNameColumnPeople.Add(new KeyValueClass("Status", 0));
            ListNameColumnPeople.Add(new KeyValueClass("Tz", 0));
            ListNameColumnPeople.Add(new KeyValueClass("HealthStatus", 0));
            List <People> lst = new List <People>();
            SqlDataReader myreader;

            myreader = People.ReadAll(0, false, true);

            while (myreader.Read())
            {
                People p = new People();
                PeopleManipulations.ReaderToPeople(ref p, ref myreader, PeopleManipulations.RtpFor.ForSearch);
                lst.Add(p);
            }
            olstpeople.BeginUpdate();
            olstpeople.SetObjects(lst);
            olstpeople.EndUpdate();
            myreader.Close();
            DBFunction.CloseConnections();
            formloadmsg.Close();
            return(true);
        }
Esempio n. 2
0
        public static User GetUser(string suser, string spass)
        {
            User          retuser = null;
            SqlDataReader reader;

            spass = SetPassword(spass);
            SqlParameter puser = new SqlParameter("@user", suser);
            SqlParameter ppass = new SqlParameter("@pass", spass);

            reader = DBFunction.ExecuteReader("SELECT * from users where username=@user and password=@pass", puser, ppass);
            if (reader != null && reader.Read())
            {
                retuser              = new User();
                retuser.Name         = (string)reader["name"];
                retuser.UserName     = (string)reader["username"];
                retuser.Password     = ReturnPassword(reader["password"].ToString());
                retuser.Email        = (string)reader["email"];
                retuser.ID           = int.Parse(reader["id"].ToString());
                retuser.Tel          = (string)reader["tel"];
                retuser.Control      = (User.TypeControl)reader["control"];
                retuser.TempPersonal = (bool)reader["TempPersonal"];
                retuser.TempGeneral  = (bool)reader["TempGeneral"];
                retuser.Sector       = (string)reader["Sector"];

                GLOBALVARS.LastUserChangeFile = DateTime.Now;
                UpdateManager.UpdateLastTimeCheck();
            }
            reader.Close();
            DBFunction.CloseConnections();
            return(retuser);
        }
Esempio n. 3
0
 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     for (int i = 0; i < 1; i++)
     {
         Log.SetDurationLogin();
     }
     for (int i = 0; i < 1; i++)
     {
         WriteSettings();
     }
     DBFunction.CloseConnections();
     Program.IdleTimer.Stop();
     Environment.Exit(0);
 }
        public void LoadShadcanim()
        {
            string sql, where;
            int    controlhide = 1, index = -1;

            Shadchanim = new ArrayList();
            if (GLOBALVARS.MyUser.Control == User.TypeControl.Admin || GLOBALVARS.MyUser.Control == User.TypeControl.Manger)
            {
                where = "";
            }
            else if (thisSideB)
            {
                where = " where id=" + ShiduchActivity.UserId;
            }
            else
            {
                where = "where id=" + GLOBALVARS.MyUser.ID;
            }
            sql = "select name,id from users " + where;
            SqlDataReader reader = DBFunction.ExecuteReader(sql);

            while (reader != null && reader.Read())
            {
                KeyValueClass temp = new KeyValueClass((string)reader["name"], (int)reader["ID"]);
                if (int.Parse(temp.Value.ToString()) == GLOBALVARS.MyUser.ID)
                {
                    if (index < 0)
                    {
                        index = txtReminderInCare.Items.Count;
                    }
                    temp.Text = "שלי";
                }
                //אם הטיפול הוא אצל מישהו אחר ממני
                if (updateActivity && int.Parse(temp.Value.ToString()) == ShiduchActivity.reminder.IdUser)
                {
                    index = txtReminderInCare.Items.Count;
                }
                Shadchanim.Add(temp);
                txtReminderInCare.Items.Add(temp);
            }
            reader.Close();
            DBFunction.CloseConnections();
            txtReminderInCare.SelectedIndex = index;
        }
Esempio n. 5
0
        private void OpenDetails(int id, bool show = true)
        {
            FormCollection fc = Application.OpenForms;

            foreach (Form frm in fc)
            {
                if (frm is DetailForm)
                {
                    ((DetailForm)frm).btnceratehtml.Enabled = false;
                    ((DetailForm)frm).btnconfirm.Enabled    = false;
                    //((DetailForm)frm).btnshowinfo.Enabled = false;
                }
            }
            if (id == 0)
            {
                return;
            }
            SqlDataReader reader;
            People        p = new People();

            p.ID   = id;
            reader = People.ReadById(p.ID);
            while (reader.Read())
            {
                PeopleManipulations.ReaderToPeople(ref p, ref reader, true, true);
            }
            reader.Close();
            DBFunction.CloseConnections();
            if (GLOBALVARS.MyUser.Control == User.TypeControl.User && p.Show == (int)People.ShowTypes.Personal)
            {
                p.OpenForPersonalEdit = true;
            }
            DetailForm detail = new DetailForm(p);

            if (show)
            {
                detail.Show(this);
            }
        }
Esempio n. 6
0
        public void LoadShadcanim()
        {
            string sql;
            //    string txt="";
            int controlhide = 1;

            GLOBALVARS.Shadchanim = new ArrayList();
            GLOBALVARS.Users      = new List <User>();
            User u;

            // cmbusers.Items.Add(new KeyValueClass("הכל", 0));
            if (GLOBALVARS.MyUser.Control == User.TypeControl.Admin)
            {
                controlhide = 100;
            }
            sql = @"select u.ID,u.name,u.tel,u.email,count(r.ByUser) as d,t1.mdate,t2.mdateexit,Sector
                    from users u left join RegisterInfo r on u.ID=r.ByUser left join
                    (select l.UserId, max(l.date) mdate from log l where l.Action=1 group by l.UserId ) t1 on t1.UserId=u.ID left join
                    (select l.UserId, max(l.DateExit) mdateexit from log l where l.Action=1  group by l.UserId ) t2 on t2.UserId=u.ID
                    where u.Control<" + controlhide + @"
                    group by u.ID,u.name,u.tel,u.email,t1.mdate,t2.mdateexit,Sector
                    order by d desc";
            SqlDataReader reader;

            reader = DBFunction.ExecuteReader(sql);
            lstchadcan.Items.Clear();
            ConnetKnow = 0;
            while (reader != null && reader.Read())
            {
                u        = new User();
                u.Name   = (string)reader["name"];
                u.ID     = (int)reader["ID"];
                u.Tel    = (string)reader["tel"];
                u.Email  = (string)reader["email"];
                u.Sector = (string)reader["Sector"];
                if (u.Sector.Length > 0)
                {
                    string[] s = u.Sector.Split(',');
                    for (int i = 0; i < s.Length; i++)
                    {
                        if (u.SectorView.Length > 0)
                        {
                            u.SectorView += ", ";
                        }
                        u.SectorView += GLOBALVARS.Sectors.ToArray()[int.Parse(s[i])].SectorName;
                    }
                }
                GLOBALVARS.Users.Add(u);
                KeyValueClass temp = new KeyValueClass((string)reader["name"], (int)reader["ID"]);
                GLOBALVARS.Shadchanim.Add(temp);
                lstchadcan.Items.Add(new ListViewItem(new string[] { (string)reader["name"],
                                                                     (string)reader["tel"], (string)reader["email"], reader["ID"].ToString(),
                                                                     reader["d"].ToString(), Connect(ref reader) }, 2));
            }
            reader.Close();
            DBFunction.CloseConnections();
            if (controlhide != 1)
            {
                lblconnect.Visible = true;
                lblconnect.Text   += ConnetKnow + " מתוך " + GLOBALVARS.Shadchanim.Count;
            }
        }
Esempio n. 7
0
        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;
        }