void AddParentNode() { // --- this method add a son node for one selected node CDocumentation_User_File oDocUserFile = new CDocumentation_User_File { Iddocumentation = -1, Idtemplate_method = null, Idconfiguration_folder = Convert.ToInt16(cbDocument.EditValue), Name_doc = "Certificado", Procedure_type = Convert.ToChar(cbProcedure.EditValue), Type_doc = 'C', Image_index = 0, Id = GetNewIdNode(), Parentid = 0, Date_ini = DateTime.Now, Date_end = DateTime.Now.AddMonths(12), Rank_valid_inmonth = 12, Prev_authorized = false }; lstDocumentation_user_file.Add(oDocUserFile); // --- save CDocumentationFactory faDocumentation = new CDocumentationFactory(); CDocumentation oDocumentation = new CDocumentation(); oDocumentation.Iddocumentation = oDocUserFile.Iddocumentation; oDocumentation.Idconfiguration_folder = oDocUserFile.Idconfiguration_folder; oDocumentation.Idtemplate_method = oDocUserFile.Idtemplate_method; oDocumentation.Image_index = oDocUserFile.Image_index; oDocumentation.Name_doc = oDocUserFile.Name_doc; oDocumentation.Procedure_type = oDocUserFile.Procedure_type; oDocumentation.Type_doc = oDocUserFile.Type_doc; oDocumentation.Flag_enabled = true; oDocumentation.Id = oDocUserFile.Id; oDocumentation.Parentid = oDocUserFile.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; faDocumentation.Insert(oDocumentation); treeAuthorization.DataSource = lstDocumentation_user_file; }
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); } } } }