public string Get_next_file_name(short iduser, char type_doc) { CDocumentation_userFactory faDocumentation_user = new CDocumentation_userFactory(); List <CDocumentation_user> lstDocumentation_user = faDocumentation_user.GetAll().Where(c => c.Iduser == iduser && c.Name_file[0] == type_doc).ToList(); long max = 0; if (lstDocumentation_user != null && lstDocumentation_user.Count() > 0) { max = lstDocumentation_user.Max(c => Convert.ToInt64(c.Order_file)); } long next = max + 1; return(String.Format("{0}-{1}", type_doc, next.ToString().PadLeft(6, '0'))); }
public List <CDocumentation_User_File> GetListDocumentation_User_File(short idconfiguration_folder, char procedure_type, short iduser, int expire) { List <CDocumentation> lstDocumentation = GetDocumentation(idconfiguration_folder, procedure_type); List <CDocumentation_user> lstDocumentation_user = new CDocumentation_userFactory().GetAll().Where(c => c.Iduser == iduser).ToList(); long?longNull = null; List <CDocumentation_User_File> lst = new List <CDocumentation_User_File>( (from l in lstDocumentation join r in lstDocumentation_user on l.Iddocumentation equals r.Iddocumentation into ps from t in ps.DefaultIfEmpty() select new CDocumentation_User_File { Iddocumentation = l.Iddocumentation, Iddocumentation_user = t == null ? longNull : Convert.ToInt64(t.Iddocumentation_user), Idconfiguration_folder = l.Idconfiguration_folder, Idtemplate_method = l.Idtemplate_method, Id = Convert.ToInt32(l.Id), Parentid = Convert.ToInt32(l.Parentid), Flag_enabled = Convert.ToBoolean(l.Flag_enabled), Image_index = Convert.ToInt32(l.Image_index), Procedure_type = Convert.ToChar(l.Procedure_type), Type_doc = Convert.ToChar(l.Type_doc), Name_doc = l.Name_doc, Name_file = t == null ? "" : t.Name_file, Allowed = t == null ? false : true, Extension_file = t == null ? "" : t.Extension_file, Date_ini = t == null ? null : t.Date_ini, Date_end = t == null ? null : t.Date_end, Prev_authorized = t == null ? false : Convert.ToBoolean(t.Prev_authorized), Rank_valid_inmonth = t == null ? 0 : Convert.ToInt32(t.Rank_valid_inmonth), Error_valid = GetErrorValid(t, expire) }).ToList()); return(lst); }
public bool IsAuthorized(ListAuthorization code, short iduser) { CDocumentation_userFactory faDocumentation_user = new CDocumentation_userFactory(); CDocumentationFactory faDocumentation = new CDocumentationFactory(); List <CDocumentation_user> lstDocUser = faDocumentation_user.GetAll(); List <CDocumentation> lstDocumentation = faDocumentation.GetAll(); var query = (from t1 in lstDocUser join t2 in lstDocumentation on t1.Iddocumentation equals t2.Iddocumentation where t2.Code == Convert.ToInt16(code) && t1.Iduser == iduser select new { Prev_authorized = t1.Prev_authorized }).ToList(); foreach (var item in query) { return(Convert.ToBoolean(item.Prev_authorized)); } return(false); }
private void treeAuthorization_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e) { if (e.Column == gcDoc_Rank_valid_inmonth || e.Column == gcDoc_Prev_authorized) { DateTime fend = Convert.ToDateTime(e.Node.GetValue("Date_ini")).AddMonths(Convert.ToInt32(e.Node.GetValue("Rank_valid_inmonth"))); e.Node.SetValue("Date_end", fend); // --- save CDocumentationFactory faDocumentation = new CDocumentationFactory(); CDocumentation oDocumentation = faDocumentation .GetByPrimaryKey(new CDocumentationKeys(Convert.ToInt16(e.Node.GetValue("Iddocumentation")))); if (oDocumentation == null) { oDocumentation = new CDocumentation(); oDocumentation.Iddocumentation = 0; } oDocumentation.Idconfiguration_folder = Convert.ToInt16(e.Node.GetValue("Idconfiguration_folder")); if (e.Node.GetValue("Idtemplate_method") != null) { oDocumentation.Idtemplate_method = Convert.ToInt32(e.Node.GetValue("Idtemplate_method")); } oDocumentation.Image_index = Convert.ToInt32(e.Node.GetValue("Image_index")); oDocumentation.Name_doc = e.Node.GetValue("Name_doc").ToString(); oDocumentation.Procedure_type = Convert.ToChar(e.Node.GetValue("Procedure_type")); oDocumentation.Type_doc = Convert.ToChar(e.Node.GetValue("Type_doc")); oDocumentation.Flag_enabled = true; oDocumentation.Id = Convert.ToInt32(e.Node.GetValue("Id")); oDocumentation.Parentid = Convert.ToInt32(e.Node.GetValue("Parentid")); oDocumentation.Usernew = Comun.GetUser(); oDocumentation.Useredit = Comun.GetUser(); oDocumentation.Datenew = DateTime.Now; oDocumentation.Dateedit = DateTime.Now; oDocumentation.Status = true; treeAuthorization.DataSource = lstDocumentation_user_file; bool result = false; if (!(result = faDocumentation.Update(oDocumentation))) { result = faDocumentation.Insert(oDocumentation); } // --- Guardar acceso el usuario if (result) { CDocumentation_userFactory faDocumentation_user = new CDocumentation_userFactory(); CDocumentation_user oDocumentation_user = new CDocumentation_user(); List <CDocumentation_user> lst = faDocumentation_user.GetAll(); if (lst.Exists(c => c.Iddocumentation == oDocumentation.Iddocumentation && c.Iduser == Convert.ToInt16(cbUser.EditValue))) { oDocumentation_user = faDocumentation_user .GetAll() .Single(c => c.Iddocumentation == oDocumentation.Iddocumentation && c.Iduser == Convert.ToInt16(cbUser.EditValue)); } else { oDocumentation_user = new CDocumentation_user(); oDocumentation_user.Iddocumentation_user = 0; } oDocumentation_user.Iddocumentation = oDocumentation.Iddocumentation; oDocumentation_user.Date_ini = Convert.ToDateTime(e.Node.GetValue("Date_ini")); oDocumentation_user.Date_end = Convert.ToDateTime(e.Node.GetValue("Date_end")); oDocumentation_user.Rank_valid_inmonth = Convert.ToInt32(e.Node.GetValue("Rank_valid_inmonth")); oDocumentation_user.Prev_authorized = Convert.ToBoolean(e.Node.GetValue("Prev_authorized")); oDocumentation_user.Iduser = Convert.ToInt16(cbUser.EditValue); if (!faDocumentation_user.Update(oDocumentation_user)) { faDocumentation_user.Insert(oDocumentation_user); } } } }
private void treeAuthorization_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e) { if (e.Column == gcDoc_Rank_valid_inmonth || e.Column == gcDoc_Prev_authorized) { DateTime fend = Convert.ToDateTime(e.Node.GetValue("Date_ini")).AddMonths(Convert.ToInt32(e.Node.GetValue("Rank_valid_inmonth"))); e.Node.SetValue("Date_end", fend); // --- save CDocumentationFactory faDocumentation = new CDocumentationFactory(); CDocumentation oDocumentation = faDocumentation .GetByPrimaryKey(new CDocumentationKeys(Convert.ToInt16(e.Node.GetValue("Iddocumentation")))); if (oDocumentation == null) { oDocumentation = new CDocumentation(); oDocumentation.Iddocumentation = 0; } oDocumentation.Idconfiguration_folder = Convert.ToInt16(e.Node.GetValue("Idconfiguration_folder")); if (e.Node.GetValue("Idtemplate_method") != null) oDocumentation.Idtemplate_method = Convert.ToInt32(e.Node.GetValue("Idtemplate_method")); oDocumentation.Image_index = Convert.ToInt32(e.Node.GetValue("Image_index")); oDocumentation.Name_doc = e.Node.GetValue("Name_doc").ToString(); oDocumentation.Procedure_type = Convert.ToChar(e.Node.GetValue("Procedure_type")); oDocumentation.Type_doc = Convert.ToChar(e.Node.GetValue("Type_doc")); oDocumentation.Flag_enabled = true; oDocumentation.Id = Convert.ToInt32(e.Node.GetValue("Id")); oDocumentation.Parentid = Convert.ToInt32(e.Node.GetValue("Parentid")); oDocumentation.Usernew = Comun.GetUser(); oDocumentation.Useredit = Comun.GetUser(); oDocumentation.Datenew = DateTime.Now; oDocumentation.Dateedit = DateTime.Now; oDocumentation.Status = true; treeAuthorization.DataSource = lstDocumentation_user_file; bool result = false; if (!(result = faDocumentation.Update(oDocumentation))) result = faDocumentation.Insert(oDocumentation); // --- Guardar acceso el usuario if (result) { CDocumentation_userFactory faDocumentation_user = new CDocumentation_userFactory(); CDocumentation_user oDocumentation_user = new CDocumentation_user(); List<CDocumentation_user> lst = faDocumentation_user.GetAll(); if (lst.Exists(c => c.Iddocumentation == oDocumentation.Iddocumentation && c.Iduser == Convert.ToInt16(cbUser.EditValue))) { oDocumentation_user = faDocumentation_user .GetAll() .Single(c => c.Iddocumentation == oDocumentation.Iddocumentation && c.Iduser == Convert.ToInt16(cbUser.EditValue)); } else { oDocumentation_user = new CDocumentation_user(); oDocumentation_user.Iddocumentation_user = 0; } oDocumentation_user.Iddocumentation = oDocumentation.Iddocumentation; oDocumentation_user.Date_ini = Convert.ToDateTime(e.Node.GetValue("Date_ini")); oDocumentation_user.Date_end = Convert.ToDateTime(e.Node.GetValue("Date_end")); oDocumentation_user.Rank_valid_inmonth = Convert.ToInt32(e.Node.GetValue("Rank_valid_inmonth")); oDocumentation_user.Prev_authorized = Convert.ToBoolean(e.Node.GetValue("Prev_authorized")); oDocumentation_user.Iduser = Convert.ToInt16(cbUser.EditValue); if (!faDocumentation_user.Update(oDocumentation_user)) faDocumentation_user.Insert(oDocumentation_user); } } }