Exemplo n.º 1
0
        private void trvDeparts_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem trv        = (TreeViewItem)trvDeparts.SelectedItem;
            string       depPrjMark = trv.Header.ToString().Split(" ").Last();

            departSelected = Conn.Db.Depart.Where(d => d.PrjMark == depPrjMark).FirstOrDefault();


            if (departSelected.Scheme == null)
            {
                return;
            }
            string svgPath = $"{AppRoot.GetApplicationRoot()}SVG\\{departSelected.Scheme}.svg";

            if (File.Exists(svgPath))
            {
                lblDepartInfo.Content = $"{departSelected.Name} {departSelected.PrjMark}";
                svgViewBox.Source     = new Uri(svgPath);
                Conn.Db.Entry(departSelected).Collection(u => u.Point).Load();
                svgCanvas.Children.Clear();
                svgCanvas.Height = svgViewBox.ActualHeight;
                foreach (Models.Point point in departSelected.Point)
                {
                    drawPoint((double)point.PosX, (double)point.PosY, point.Id, svgCanvas);
                }
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <DepartViewModel> > UpdateDepart(int id, DepartViewModel departViewModel)
        {
            try
            {
                if (id != departViewModel.Depart.Id)
                {
                    return(BadRequest("Depart ID mismatch"));
                }

                var departToUpdate = await departRepository.GetDepart(id);

                if (departToUpdate == null)
                {
                    return(NotFound($"Depart with Id = {id} not found"));
                }

                // Add custom model validation error
                Depart dep = await departRepository.GetDepartByname(departViewModel.Depart);

                if (dep != null)
                {
                    ModelState.AddModelError("Name", $"Depart name: {departViewModel.Depart.Name} already in use");
                    return(BadRequest(ModelState));
                }

                return(await departRepository.UpdateDepart(departViewModel));
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                string SourceFile = "wwwroot/images/picture.png";
                var    user       = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, Kind = model.Kind
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                    await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl);

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    _logger.LogInformation("User created a new account with password.");
                    bool isrewrite = true;
                    if (model.Kind == "Department")
                    {
                        var depart = new Depart {
                            Email = model.Email, PictureNum = 0
                        };
                        await _applicationDbContext.Departs.AddAsync(depart);

                        await _applicationDbContext.SaveChangesAsync();

                        long id = depart.ID;
                        Directory.CreateDirectory(Constants.FilePathD + id.ToString() + "/");
                        string desFile = Constants.FilePathD + id.ToString() + "/picture.jpg";
                        System.IO.File.Copy(SourceFile, desFile, isrewrite);
                        return(RedirectToAction("IndexD", new { id }));
                    }
                    else
                    {
                        var stu = new Student {
                            Email = model.Email
                        };
                        await _applicationDbContext.Students.AddAsync(stu);

                        await _applicationDbContext.SaveChangesAsync();

                        long id = stu.ID;
                        Directory.CreateDirectory(Constants.FilePathS + id.ToString() + "/");
                        string desFile = Constants.FilePathS + id.ToString() + "/picture.jpg";
                        System.IO.File.Copy(SourceFile, desFile, isrewrite);
                        return(RedirectToAction("IndexS", new { id }));
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 4
0
    /// <summary>
    /// 显示日程信息
    /// </summary>
    /// <param name="schedule"></param>
    private void ShowSchedule(Schedule schedule)
    {
        this.txtTitle.Text     = schedule.Title;
        this.txtAddress.Text   = schedule.SchContent;
        this.txtBeginTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", schedule.BeginTime);
        this.txtEndTime.Text   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", schedule.EndTime);
        this.txtContent.Text   = schedule.SchContent;
        this.lblUserName.Text  = schedule.CreateUser.UserName;
        IList <PreContract> preContracts = PreContractManager.GetPreContractByScheduleId(schedule.ScheduleId);

        if (preContracts.Count != 0)
        {
            foreach (PreContract pre in preContracts)
            {
                User     us     = UserManager.GetUserById(pre.UserId);
                Depart   depart = DepartInfoManager.GetDepartGetById(us.DepartId);
                ListItem item   = new ListItem(depart.DepartName + "-" + us.UserName, us.UserId);
                this.lbUserName.Items.Add(item);
            }
        }
        if (schedule.IfPrivate == 1)
        {
            this.cboPrivate.Checked = true;
        }
        else
        {
            this.cboPrivate.Checked = false;
        }
        this.ddlType.SelectedValue = schedule.Meeting.MeetingId.ToString();
    }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //设置只读权限
                if (Request.QueryString["type"] == "read")
                {
                    btn_submit.Visible = false;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "$(function(){$('input').attr('readonly', 'readonly');$('select').attr('disabled', 'true');$('textarea').attr('readonly', 'readonly');});", true);
                }

                //专业类别
                ProjectTypes.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(56);
                ProjectTypes.DataTextField  = "ClassName";
                ProjectTypes.DataValueField = "ClassName";
                ProjectTypes.DataBind();
                //级别
                ProjectLevel.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(58);
                ProjectLevel.DataTextField  = "ClassName";
                ProjectLevel.DataValueField = "ClassName";
                ProjectLevel.DataBind();
                //部门
                Depart.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(52);
                Depart.DataTextField  = "ClassName";
                Depart.DataValueField = "ClassName";
                Depart.DataBind();
                Depart.Items.Insert(0, new ListItem("选择部门", ""));

                Bind();
            }
        }
Exemplo n.º 6
0
        public async Task <ActionResult <DepartViewModel> > CreateDepart(DepartViewModel departViewModel)
        {
            try
            {
                if (departViewModel == null)
                {
                    return(BadRequest());
                }

                // Add custom model validation error
                Depart dep = await departRepository.GetDepartByname(departViewModel.Depart);

                if (dep != null)
                {
                    ModelState.AddModelError("Name", $"Depart name: {departViewModel.Depart.Name} already in use");
                    return(BadRequest(ModelState));
                }

                departViewModel = await departRepository.AddDepart(departViewModel);

                return(CreatedAtAction(nameof(GetDepart),
                                       new { id = departViewModel.Depart.Id }, departViewModel));
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            string d = new Depart(); //ajouter le bon namespace pour trouver la methode.

            Console.WriteLine(d);
            //return Depart;
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <DepartInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <DepartInfo> list = new List <DepartInfo>();

            Query q = Depart.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            DepartCollection collection = new  DepartCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Depart depart  in collection)
            {
                DepartInfo departInfo = new DepartInfo();
                LoadFromDAL(departInfo, depart);
                list.Add(departInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Exemplo n.º 9
0
        //根据部门名称获取部门ID
        public Depart findDpartByName(string DepartName)
        {
            Depart depart = null;
            string sql    = "select * from xk.depart where name = @departname";

            MySqlParameter[] pars =
            {
                new MySqlParameter("@departname", MySqlDbType.VarChar)
            };
            pars[0].Value = DepartName;

            DataTable dt = SqlHelper.GetTable(sql, CommandType.Text, pars);

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                depart      = new Depart();//实例化 ,并且将此条数据保存到depart对象中
                depart.id   = Int32.Parse(row["id"].ToString());
                depart.name = row["name"].ToString();
                depart.desc = row["desc"].ToString();
                return(depart);
            }
            else
            {
                return(depart);
            }
        }
Exemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //专业类别
         ProjectTypes.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(56);
         ProjectTypes.DataTextField  = "ClassName";
         ProjectTypes.DataValueField = "ClassName";
         ProjectTypes.DataBind();
         ProjectTypes.Items.Insert(0, new ListItem("选择类型", ""));
         //级别
         ProjectLevel.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(58);
         ProjectLevel.DataTextField  = "ClassName";
         ProjectLevel.DataValueField = "ClassName";
         ProjectLevel.DataBind();
         ProjectLevel.Items.Insert(0, new ListItem("选择级别", ""));
         //部门
         Depart.DataSource     = WebBLL.Tbl_ClassManager.GetTbl_ClassByParentID(52);
         Depart.DataTextField  = "ClassName";
         Depart.DataValueField = "ClassName";
         Depart.DataBind();
         Depart.Items.Insert(0, new ListItem("选择部门", ""));
         ProjectManager.Items.Insert(0, new ListItem("选择负责人", ""));
     }
 }
        /// <summary>
        /// DELETE Department method
        /// </summary>
        /// <param name="depart"></param>
        /// <returns>
        /// bool value of method's execution
        /// </returns>
        public static bool Remove(Depart depart)
        {
            using (EquipmentsEntities context = new EquipmentsEntities())
            {
                try
                {
                    int        id   = Convert.ToInt32(depart.Id);
                    DeptEntity dept = context.Depts.Single(d => d.Id == id);

                    context.Depts.Remove(dept);

                    var equipments = context.Equip.Where(e => e.DeptsId == dept.Id).ToList();

                    foreach (var eq in equipments)
                    {
                        eq.DeptsId = null;
                    }

                    context.SaveChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 12
0
        protected void Depart_PreRend(object sender, EventArgs e)
        {
            DBContext dBContext = new DBContext();

            Depart.DataSource = (from d in dBContext.Departements select d.NomDep).ToList();
            Depart.DataBind();
        }
Exemplo n.º 13
0
        private void dgvDeparts_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName  = dgvDeparts.Columns[e.ColumnIndex].Name;
            int    idDepart = Convert.ToInt32(dgvDeparts.Rows[e.RowIndex].Cells["ID"].Value);

            if (colName == "btnDel")
            {
                DialogResult dr = MessageBox.Show("Voulez vous vraiment supprimer ce courrier ?",
                                                  "Confirmation de Suppression",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Warning
                                                  );
                if (dr == DialogResult.Yes)
                {
                    using (DBGCourriesContext db = new DBGCourriesContext())
                    {
                        Depart depart = db.Depart.FirstOrDefault(d => d.idDepart == idDepart);
                        depart.Entites.Clear();// supprimer toutes les entités liées au courrier depart (table destiner)

                        List <DepartDocs> docsToDelete = db.DepartDocs.Where(d => d.idDepart == idDepart).ToList();
                        db.DepartDocs.RemoveRange(docsToDelete);

                        db.Depart.Remove(depart);
                        db.SaveChanges();
                        LoadListDepart();
                    }
                }
            }

            if (colName == "btnEdit")
            {
                EditDepart frmEdit = new EditDepart(idDepart, this);
                frmEdit.ShowDialog();
            }
        }
        public ActionResult Edit(Depart model)
        {
            _department = new MockDepartment();

            _department.UpdateDepartment(model);
            return(RedirectToAction("List"));
        }
        public ActionResult Create(Depart model)
        {
            _department = new MockDepartment();

            _department.InsertDepartment(model);
            return(RedirectToAction("List"));
        }
Exemplo n.º 16
0
        //页面加载
        //public static PageList getDepart(int pageIndex, int pageSize)
        //{
        //    WarehouseEntities con = new WarehouseEntities();
        //    PageList list = new PageList();
        //    var obj = from p in con.Depart
        //              where p.IsDelete == 0
        //              orderby p.Id
        //              select new
        //              {
        //                  Id = p.Id,
        //                  DepartNum = p.DepartNum,
        //                  DepartName = p.DepartName,
        //                  CreateTime = p.CreateTime
        //              };
        //    list.DataList = obj.Skip((pageIndex - 1) * pageSize).Take(pageSize);
        //    //设置总页数
        //    int rows = obj.Count();
        //    list.PageCount = rows; //rows % pageSize == 0 ? rows / pageSize : rows / pageSize + 1;

        //    return list;
        //}

        //新增
        public static int Add(Depart det)
        {
            WarehouseEntities con = new WarehouseEntities();

            con.Depart.Add(det);
            return(con.SaveChanges());
        }
Exemplo n.º 17
0
 /// <summary>
 /// 在当前对象的同级(兄弟中),该对象是否重名,
 /// </summary>
 /// <param name="entity">业务实体</param>
 /// <param name="isSibling">是否限制在当前层的判断;true,表示仅在当前层判断,false表示在所有对象中判断</param>
 /// <returns></returns>
 public bool IsExist(int orgid, Depart entity, bool isSibling)
 {
     //在当前兄弟中判断
     if (isSibling)
     {
         Depart mm = null;
         //如果是一个新对象
         if (entity.Dep_Id == 0)
         {
             mm = Gateway.Default.From <Depart>()
                  .Where(Depart._.Org_ID == orgid && Depart._.Dep_CnName == entity.Dep_CnName && Depart._.Dep_PatId == entity.Dep_PatId)
                  .ToFirst <Depart>();
         }
         else
         {
             //如果是一个已经存在的对象,则不匹配自己
             mm = Gateway.Default.From <Depart>()
                  .Where(Depart._.Org_ID == orgid && Depart._.Dep_CnName == entity.Dep_CnName && Depart._.Dep_Id != entity.Dep_CnName && Depart._.Dep_PatId == entity.Dep_PatId)
                  .ToFirst <Depart>();
         }
         return(mm != null);
     }
     //在所有对象有判断
     return(IsExist(orgid, entity));
 }
Exemplo n.º 18
0
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool AddDepart(Depart m)
        {
            string sql = $"insert into Depart(Name) values({m.Name})";
            bool   h   = SqlDbHelper.ExecuteNonQuery(sql);

            return(h);
        }
Exemplo n.º 19
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void Save(Depart entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <Depart>(entity);
             tran.Update <EmpAccount>(new Field[] { EmpAccount._.Dep_CnName }, new object[] { entity.Dep_CnName }, EmpAccount._.Dep_Id == entity.Dep_Id);
             tran.Update <Subject>(new Field[] { Subject._.Dep_CnName }, new object[] { entity.Dep_CnName }, Subject._.Dep_Id == entity.Dep_Id);
             tran.Update <Course>(new Field[] { Course._.Dep_CnName }, new object[] { entity.Dep_CnName }, Course._.Dep_Id == entity.Dep_Id);
             //tran.Update<Teacher>(new Field[] { Teacher._.Dep_CnName }, new object[] { entity.Dep_CnName }, Teacher._.Dep_Id == entity.Dep_Id);
             tran.Update <StudentSort>(new Field[] { StudentSort._.Dep_CnName }, new object[] { entity.Dep_CnName }, StudentSort._.Dep_Id == entity.Dep_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// 根据部门Id查询部门信息
        /// </summary>
        /// <param name="departId"></param>
        /// <returns></returns>
        public static Depart GetDepartGetById(int departId)
        {
            string sql = "select * from DepartInfo where DepartId=" + departId;

            using (SqlDataReader reader = DBHelper.GetReader(sql))
            {
                if (reader.Read())
                {
                    Depart depart = new Depart();
                    depart.DepartId   = (int)reader["DepartId"];
                    depart.DepartName = (string)reader["DepartName"];
                    string PrincipalUser = (string)reader["PrincipalUser"];
                    depart.ConnectTelNo       = (long)reader["ConnectTelNo"];
                    depart.ConnectMobileTelNo = (long)reader["ConnectMobileTelNo"];
                    depart.Faxes = (long)reader["Faxes"];
                    int branchId = (int)reader["BranchId"];
                    reader.Close();
                    depart.Branch        = BranchService.GetBranchById(branchId);
                    depart.PrincipalUser = UserService.GetUserById(PrincipalUser);
                    return(depart);
                }
                else
                {
                    reader.Close();
                    return(null);
                }
            }
        }
Exemplo n.º 21
0
        //数据持久化
        internal static void  SaveToDb(DepartInfo pDepartInfo, Depart pDepart, bool pIsNew)
        {
            pDepart.DepartId   = pDepartInfo.departId;
            pDepart.DepartName = pDepartInfo.departName;
            pDepart.IsNew      = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pDepart.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(DepartInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pDepartInfo.departId = pDepart.DepartId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(DepartInfo)))
            {
                ResetCache();
            }
        }
Exemplo n.º 22
0
        public IHttpActionResult PutDepart(int id, Depart depart)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != depart.Iddep)
            {
                return(BadRequest());
            }

            db.Entry(depart).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 23
0
        public ActionResult DeleteConfirmed(int id)
        {
            Depart depart = db.Departs.Find(id);

            db.Departs.Remove(depart);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 24
0
        private void EditDepart_Load(object sender, EventArgs e)
        {
            if (this.idDepart != 0)
            {
                txtTitre.Text = "Edition Courrier Départ N° :" + this.idDepart;
                using (DBGCourriesContext db = new DBGCourriesContext())
                {
                    txtCateg.DataSource    = db.Categorie.ToList();
                    txtCateg.DisplayMember = "LibCateg";
                    txtCateg.ValueMember   = "idCateg";

                    txtEntite.DataSource    = db.Entites.ToList();
                    txtEntite.DisplayMember = "LibEntite";
                    txtEntite.ValueMember   = "idEntite";

                    Depart dep = db.Depart.FirstOrDefault(x => x.idDepart == this.idDepart);
                    txtDateOrdre.Value    = dep.DateOrdre.Date;
                    txtSujet.Text         = dep.Sujet;
                    txtRemarque.Text      = dep.Remarques;
                    txtCateg.SelectedItem = dep.Categorie;

                    foreach (Entites entite in dep.Entites)
                    {
                        for (int i = 0; i < txtEntite.Items.Count; i++)
                        {
                            if (entite.idEntite == ((Entites)txtEntite.Items[i]).idEntite)
                            {
                                txtEntite.SetItemChecked(i, true);
                            }
                        }
                    }

                    // charger les fichiers de ce courrier départ
                    loadDepartDocs();
                    dgvDepartDocs.Columns["idDepart"].Visible    = false;
                    dgvDepartDocs.Columns["idDocDepart"].Visible = false;
                    dgvDepartDocs.ColumnHeadersVisible           = false;
                    dgvDepartDocs.RowHeadersVisible = false;

                    DataGridViewImageColumn btnDowload = new DataGridViewImageColumn();
                    btnDowload.Name       = "btnDowload";
                    btnDowload.HeaderText = "";
                    btnDowload.Image      = Properties.Resources.download3;
                    dgvDepartDocs.Columns.Add(btnDowload);


                    DataGridViewImageColumn btnDelete = new DataGridViewImageColumn();
                    btnDelete.Name       = "btnDelete";
                    btnDelete.HeaderText = "";
                    btnDelete.Image      = Properties.Resources.delete1;
                    dgvDepartDocs.Columns.Add(btnDelete);

                    dgvDepartDocs.Columns["btnDowload"].DefaultCellStyle.Padding = new Padding(5, 5, 5, 5);
                    dgvDepartDocs.Columns["btnDelete"].DefaultCellStyle.Padding  = new Padding(5, 5, 5, 5);
                    dgvDepartDocs.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                }
            }
        }
Exemplo n.º 25
0
        public ActionResult Edit(Depart o)
        {
            var t = obj.Where(a => a.id == o.id).FirstOrDefault();

            t.name     = o.name;
            t.password = o.password;
            t.age      = o.age;
            return(RedirectToAction("Select", "Home"));
        }
Exemplo n.º 26
0
        internal static DepartPanel Instance(Node parent, Depart depart)
        {
            var panel = (DepartPanel)ResourceLoader.Load <PackedScene>(path).Instance();

            panel.gmObj = depart;

            parent.AddChild(panel);
            return(panel);
        }
Exemplo n.º 27
0
        public void AddDepart(Depart m)
        {
            string str = client.Post("User/AddDepart", JsonConvert.SerializeObject(m));
            int    h   = int.Parse(str);

            if (h > 0)
            {
                Response.Write("<script>alert('添加成功');location.href='/User/Index'</script>");
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">业务实体</param>
        public void Delete(Depart entity)
        {
            Depart dep = Gateway.Default.From <Depart>().Where(Depart._.Dep_Id == entity.Dep_Id).ToFirst <Depart>();

            if (dep == null)
            {
                return;
            }
            this.Delete(dep.Dep_Id);
        }
Exemplo n.º 29
0
 public ActionResult Edit([Bind(Include = "DepID,DepName,HOD")] Depart depart)
 {
     if (ModelState.IsValid)
     {
         db.Entry(depart).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(depart));
 }
Exemplo n.º 30
0
        /// <summary>
        /// 获取当前对象的父级对象;
        /// </summary>
        /// <param name="identify">当前实体的主键</param>
        /// <returns></returns>
        public Depart GetParent(int identify)
        {
            Depart mm = this.GetSingle(identify);

            if (mm == null)
            {
                return(null);
            }
            return(this.GetSingle(mm.Dep_Id));
        }
Exemplo n.º 31
0
        public void ShowDepart()
        {
            var departForm = new Depart();
            departForm.SetMdiParent(_mainForm.GetForm());
            DepLogic depLogic = new DepLogic(_context);
            var departPresenter = new DepartPresenter(departForm, depLogic);
//            Task.Factory.StartNew(() => { depLogic.Work(); });

            Thread myThread = new Thread(new ThreadStart(depLogic.Work));
            myThread.Name = "Поток ";
            myThread.IsBackground = true;
            myThread.Start();

            //departForm.MdiParent = this;
            departForm.Show();
        }
Exemplo n.º 32
0
 private void LoadFromId(int departId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(DepartInfo)))
     {
         DepartInfo departInfo=Find(GetList(), departId);
         if(departInfo==null)
             throw new AppException("未能在缓存中找到相应的键值对象");
         Copy(departInfo, this);
     }
     else
     {	Depart depart=new Depart( departId);
         if(depart.IsNew)
         throw new AppException("尚未初始化");
        	LoadFromDAL(this, depart);
     }
 }
Exemplo n.º 33
0
 //数据持久化
 internal static void SaveToDb(DepartInfo pDepartInfo, Depart  pDepart,bool pIsNew)
 {
     pDepart.DepartId = pDepartInfo.departId;
      		pDepart.DepartName = pDepartInfo.departName;
     pDepart.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pDepart.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(DepartInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pDepartInfo.departId = pDepart.DepartId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(DepartInfo)))
     {
         ResetCache();
     }
 }
Exemplo n.º 34
0
 //从后台获取数据
 internal static void LoadFromDAL(DepartInfo pDepartInfo, Depart  pDepart)
 {
     pDepartInfo.departId = pDepart.DepartId;
      		pDepartInfo.departName = pDepart.DepartName;
     pDepartInfo.Loaded=true;
 }
Exemplo n.º 35
0
 /// <summary>
 /// 保存
 /// </summary>
 public override void Save()
 {
     if(!m_Loaded)//新增
     {
         Depart depart=new Depart();
         SaveToDb(this, depart,true);
     }
     else//修改
     {
         Depart depart=new Depart(departId);
         if(depart.IsNew)
             throw new AppException("该数据已经不存在了");
         SaveToDb(this, depart,false);
     }
 }