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 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);
        }
Пример #3
0
        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);
                    }
                }
            }
        }
Пример #4
0
        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);
                }
            }
        }