示例#1
0
 private void comboBoxTenant_SelectedValueChanged(object sender, EventArgs e)
 {
     comboBoxCate.DataSource = null;
     using (CategoriesService objserv = new CategoriesService())
     {
         int tenantid = AppBase.CInt(comboBoxTenant.SelectedValue.ToString());
         var list     = objserv.Reposity.GetAllList(o => o.TenantId == tenantid && o.Layout == "Zone" && o.Level == 3);
         comboBoxCate.DataSource    = list.Select(o => new { o.CategoryName, o.Id }).ToList();
         comboBoxCate.DisplayMember = "CategoryName";
         comboBoxCate.ValueMember   = "Id";
     }
 }
示例#2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string username = textBoxUser.Text;
            string password = textBoxPsw.Text;
            int    tenantid = AppBase.CInt(comboBoxTenant.SelectedValue);
            int    cateid   = AppBase.CInt(comboBoxCate.SelectedValue);

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("请输入用户名和密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (tenantid == 0)
            {
                MessageBox.Show("请选择站点!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cateid == 0)
            {
                MessageBox.Show("请选择社区!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            using (AdminsService admin = new AdminsService())
            {
                var model = admin.Reposity.GetAllList().Where(o => o.LoginName == username).FirstOrDefault();
                if (model != null)
                {
                    if (model.Password == password)
                    {
                        FormMain form = new FormMain(tenantid, cateid, model.Id, comboBoxCate.Text, model.LoginName);
                        form.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("用户不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
示例#3
0
        private void UploadMember()
        {
            toolBtnUpload.Enabled = false;
            Task.Run(() =>
            {
                MembersService ObjServ     = new MembersService();
                MembersService ObjServRead = new MembersService();

                errorRow = 0;
                compRow  = 0;
                List <Members> members = new List <Members>();
                try
                {
                    members = ObjServRead.Reposity.GetAllList(o => o.TenantId == TenantId);
                }
                catch (Exception ex)
                {
                    this.BeginInvoke(new Action(() =>
                    {
                        textBoxError.Text = "获取数据错误:" + ex.Message + "\r\n";
                    }));
                }
                ObjServRead.Dispose();
                foreach (DataGridViewRow row in dgvMain.Rows)
                {
                    if (row != null)
                    {
                        string userid = row.Cells["身份证号"].Value != null ? row.Cells["身份证号"].Value.ToString() : "";
                        try
                        {
                            var obj = members.Where(o => o.UserID == userid && o.UserID != "0").FirstOrDefault();
                            if (obj != null)
                            {
                                #region update
                                obj.TrueName  = row.Cells["姓名"].Value.ToString();
                                obj.Relations = row.Cells["关系"].Value.ToString();
                                obj.Sex       = row.Cells["性别"].Value.ToString();
                                obj.Nation    = row.Cells["民族"].Value.ToString();
                                //obj.Birthday = row.Cells["出生年月"].Value.ToString();
                                obj.Age                    = AppBase.CInt(row.Cells["年龄"].Value);
                                obj.Apartment              = row.Cells["楼盘"].Value.ToString();
                                obj.UnitNum                = row.Cells["单元"].Value.ToString();
                                obj.DoorCard               = row.Cells["门牌号"].Value.ToString();
                                obj.UserID                 = row.Cells["身份证号"].Value.ToString();
                                obj.Address                = row.Cells["现户籍地址"].Value.ToString();
                                obj.Address2               = row.Cells["原户籍地址"].Value.ToString();
                                obj.HhdRegister            = row.Cells["是否兴塘社区户籍"].Value.ToString() == "是";
                                obj.ServiceAddr            = row.Cells["服务处所"].Value.ToString();
                                obj.Duties                 = row.Cells["职务"].Value.ToString();
                                obj.Phone                  = row.Cells["联系电话1"].Value.ToString();
                                obj.Phone2                 = row.Cells["联系电话2"].Value.ToString();
                                obj.PoliticalRole          = row.Cells["政治面貌"].Value.ToString();
                                obj.PartyBranch            = row.Cells["党员所在支部"].Value.ToString();
                                obj.CorridorLeader         = row.Cells["是否楼道组长"].Value.ToString() == "是";
                                obj.HouseLeader            = row.Cells["是否户代表"].Value.ToString() == "是";
                                obj.ResidentRepresentative = row.Cells["是否居民代表"].Value.ToString() == "是";
                                obj.ResidentLeader         = row.Cells["是否居民组长"].Value.ToString() == "是";
                                obj.Pipwa                  = row.Cells["是否愿意参加公益"].Value.ToString() == "是";
                                obj.Eira                   = row.Cells["是否愿意从事居民事务"].Value.ToString() == "是";
                                obj.UpdateTime             = DateTime.Now;
                                obj.Speciality             = row.Cells["特长备注"].Value.ToString();
                                obj.TenantId               = TenantId;
                                obj.Community              = Community;
                                obj.IsReger                = false;
                                ObjServ.Reposity.Update(obj);
                                #endregion
                            }
                            else
                            {
                                #region insert
                                Members entity                = new Members();
                                entity.TrueName               = row.Cells["姓名"].Value.ToString();
                                entity.Relations              = row.Cells["关系"].Value.ToString();
                                entity.Nation                 = row.Cells["民族"].Value.ToString();
                                entity.Apartment              = row.Cells["楼盘"].Value.ToString();
                                entity.UnitNum                = row.Cells["单元"].Value.ToString();
                                entity.DoorCard               = row.Cells["门牌号"].Value.ToString();
                                entity.UserID                 = row.Cells["身份证号"].Value.ToString();
                                entity.Address                = row.Cells["现户籍地址"].Value.ToString();
                                entity.Address2               = row.Cells["原户籍地址"].Value.ToString();
                                entity.HhdRegister            = row.Cells["是否兴塘社区户籍"].Value.ToString() == "是";
                                entity.ServiceAddr            = row.Cells["服务处所"].Value.ToString();
                                entity.Duties                 = row.Cells["职务"].Value.ToString();
                                entity.Phone                  = row.Cells["联系电话1"].Value.ToString();
                                entity.Phone2                 = row.Cells["联系电话2"].Value.ToString();
                                entity.PoliticalRole          = row.Cells["政治面貌"].Value.ToString();
                                entity.PartyBranch            = row.Cells["党员所在支部"].Value.ToString();
                                entity.CorridorLeader         = row.Cells["是否楼道组长"].Value.ToString() == "是";
                                entity.HouseLeader            = row.Cells["是否户代表"].Value.ToString() == "是";
                                entity.ResidentRepresentative = row.Cells["是否居民代表"].Value.ToString() == "是";
                                entity.ResidentLeader         = row.Cells["是否居民组长"].Value.ToString() == "是";
                                entity.Pipwa                  = row.Cells["是否愿意参加公益"].Value.ToString() == "是";
                                entity.Eira         = row.Cells["是否愿意从事居民事务"].Value.ToString() == "是";
                                entity.UpdateTime   = DateTime.Now;
                                entity.Speciality   = row.Cells["特长备注"].Value.ToString();
                                entity.UserName     = AppBase.GetRndCode(6);
                                entity.Password     = "******";
                                entity.Email        = "-";
                                entity.CreationTime = DateTime.Now;
                                entity.TenantId     = TenantId;
                                entity.Community    = Community;
                                entity.IsReger      = false;
                                BirthdayAgeSex user = AppBase.GetBirthdayAgeSex(entity.UserID);
                                if (user != null)
                                {
                                    entity.Age      = user.Age;
                                    entity.Birthday = user.Birthday;
                                    entity.Sex      = user.Sex;
                                }
                                else
                                {
                                    entity.UserID = "no valid";
                                }
                                ObjServ.Reposity.Insert(entity);
                                #endregion
                            }
                        }
                        catch (Exception ex)
                        {
                            errorRow++;
                            this.BeginInvoke(new Action(() =>
                            {
                                textBoxError.Text += "导入[" + userid + "]发生错误:" + ex.Message + "      ";
                            }));
                        }
                        compRow++;
                        this.BeginInvoke(new Action(() =>
                        {
                            progressBarM.Value    = compRow > progressBarM.Maximum ? progressBarM.Maximum : compRow;
                            labelCount.Text       = "完成:" + progressBarM.Value + "/" + totalRow;
                            labelError.Text       = "错误:" + (errorRow > progressBarM.Maximum ? progressBarM.Maximum : errorRow);
                            toolBtnUpload.Enabled = progressBarM.Value == totalRow;
                            if (totalRow == progressBarM.Value)
                            {
                                MessageBox.Show("导入完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }));
                    }
                }
                ObjServ.Dispose();
            });
        }