Exemple #1
0
        private void saveUserInfo()
        {
            for (int i = 0; i < DT_UserInfo.Rows.Count; i++)
            {
                if (DT_UserInfo.Rows[i]["RealName"].ToString().Trim() == Cur_UsrName)
                {
                    DT_UserInfo.Rows[i]["DistrictCode"] = DT_UserInfo.Rows[i]["Type"];
                    DT_UserInfo.Rows[i]["DistrictName"] = null;

                    for (int j = 0; j < CLB_Districts.Items.Count; j++)
                    {
                        if (CLB_Districts.GetItemChecked(j))
                        {
                            DT_UserInfo.Rows[i]["DistrictCode"] += districts[j].districtCode + ",";
                            DT_UserInfo.Rows[i]["DistrictName"] += districts[j].districtName + ",";
                        }
                    }
                    if (DT_UserInfo.Rows[i]["DistrictName"].ToString().Trim().Length > 0)
                    {
                        DT_UserInfo.Rows[i]["DistrictCode"] = DT_UserInfo.Rows[i]["DistrictCode"].ToString().Trim().Substring(1, DT_UserInfo.Rows[i]["DistrictCode"].ToString().Trim().Length - 2);
                        DT_UserInfo.Rows[i]["DistrictName"] = DT_UserInfo.Rows[i]["DistrictName"].ToString().Trim().Substring(0, DT_UserInfo.Rows[i]["DistrictName"].ToString().Trim().Length - 1);
                    }

                    break;
                }
            }
        }
Exemple #2
0
        private void CLB_Districts_MouseClick(object sender, MouseEventArgs e)
        {
            int index = this.CLB_Districts.IndexFromPoint(e.Location);

            if (index != CheckedListBox.NoMatches)
            {
                CLB_Districts.SetItemChecked(index, !CLB_Districts.GetItemChecked(index));
            }
            else
            {
                CLB_Districts.SelectedIndex = -1;//不做任何操作,将ListBox的选中项取消
            }
        }
Exemple #3
0
        //保存当前更改项
        private void saveUsrChanges()
        {
            var user = userInfoDatas.Where(x => x.Account == CurAccount).FirstOrDefault();

            userInfoDatas.Remove(user);
            user.DistrictCode = "";
            user.DistrictName = "";
            for (int i = 0; i < CLB_Districts.Items.Count; i++)
            {
                if (CLB_Districts.GetItemChecked(i))
                {
                    var temp = districtInfoDatas.Where(x => x.DistrictName == CLB_Districts.Items[i].ToString()).FirstOrDefault();
                    user.DistrictCode += temp.DistrictCode + ",";
                    user.DistrictName += temp.DistrictName + ",";
                }
            }
            if (user.DistrictCode.Length > 0)
            {
                user.DistrictCode = user.DistrictCode.Substring(0, user.DistrictCode.Length - 1);
                user.DistrictName = user.DistrictName.Substring(0, user.DistrictName.Length - 1);
            }
            userInfoDatas.Add(user);
        }