protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gvOrg.DataSource = mem.getAllMembershipDetailOrg();
                gvOrg.DataBind();
                gvOrg.HeaderRow.TableSection = TableRowSection.TableHeader;
                Session.Add("OrganisationID", null);

                gvPerson.DataSource = mem.getAllMembershipDetailPerson();
                gvPerson.DataBind();
                gvPerson.UseAccessibleHeader    = true;
                gvPerson.HeaderRow.TableSection = TableRowSection.TableHeader;
                Session.Add("IndividualID", null);

                DatabaseDAO d1 = new DatabaseDAO();
                DataTable   DT = new DataTable();
                DT = d1.GetLookupSearch("HONOURIFIC");
                IndDdlHonorific.DataSource     = DT;
                IndDdlHonorific.DataTextField  = "Code";
                IndDdlHonorific.DataValueField = "Code"; //When insert, this value
                IndDdlHonorific.DataBind();
            }
            else
            {
                //If error, display failure message
                ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DatabaseDAO d1 = new DatabaseDAO();
            DataTable   DT = new DataTable();

            DT = d1.GetLookupSearch("HONOURIFIC");
            ddlList.DataSource     = DT;
            ddlList.DataTextField  = "Code_Desc";
            ddlList.DataValueField = "Code"; //When insert, this value
            ddlList.DataBind();


            pList = (ArrayList)Session["indvPerson"];


            // Below 3 lines do not work
            //detailList = (ArrayList)Session["CAREP_Details"];
            //associateType.InnerText = detailList[0].ToString();
            //bindPAtable();

            //if (IsPostBack)
            //{
            //    associateType.InnerText = pList[3].ToString();

            //}
        }
Example #3
0
        public ResultadoOperacionEnum.ResultadoOperacion IniciarRespaldo(String ruta)
        {
            ResultadoOperacionEnum.ResultadoOperacion resultado = ResultadoOperacionEnum.ResultadoOperacion.FallaDesconocida;
            DatabaseDAO databaseDAO = new DatabaseDAO();

            resultado = databaseDAO.ObtenerRespaldo(ruta);
            return(resultado);
        }
Example #4
0
        public static int checkLookUp(string IDVal, string type)
        {
            int         check = 0;
            DatabaseDAO dao   = new DatabaseDAO();

            check = dao.checkLookUpValidity(IDVal, type);
            return(check);
        }
Example #5
0
        public static int checkUserName(string IDVal)
        {
            int         check = 0;
            DatabaseDAO dao   = new DatabaseDAO();

            check = dao.checkIDValidity(IDVal);
            return(check);
        }
Example #6
0
        protected void Submit_User(object sender, EventArgs e)
        {
            if ((string)(Session["UserID"]) == null)
            {
                int check = 0;
                try
                {
                    DatabaseDAO user = new DatabaseDAO();
                    check = user.AddUser(User_Input_Username.Value, User_Input_Name.Value, User_Input_Email.Value, DateTime.Now, Select_Permission_Level.Value);


                    if (check == 1)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displaySuccess('Successfully Created New Account: " + User_Input_Name.Value + " With Permission Level Of: " + Select_Permission_Level.Value + "');", true);
                    }
                    else if (check == 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure('There seems to be an error! Please notify the Administrators.');", true);
                    }

                    User_Input_Name.Value = "";

                    User_Input_Email.Value = "";
                    Select_Permission_Level.SelectedIndex = 0;
                    User_Input_Username.Value             = "";
                }
                catch (Exception ex)
                {
                    ErrorLog.WriteErrorLog(ex.ToString());
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                }
            }
            else
            {
                int check = 0;
                try
                {
                    string      UserID = (string)(Session["UserID"]);
                    DatabaseDAO user   = new DatabaseDAO();
                    check = user.EditUser(User_Input_Name.Value, User_Input_Email.Value, Select_Permission_Level.Value, User_Input_Username.Value, UserID, DateTime.Now);
                    if (check == 1)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displaySuccess('Successfully Updated Account:" + User_Input_Name.Value + "');", true);
                    }
                    else if (check == 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog.WriteErrorLog(ex.ToString());
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                }
            }
        }
Example #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            if (!string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                if (txtPassword.Text != txtPasswordAgain.Text)
                {
                    HELPER.Client.Alert(this, "Mật khẩu không trùng khớp!");
                    return;
                }
            }

            objUser = new BUS.BUS_Users(dao);
            try
            {
                HELPER.CWebPage.BindProperty(objUser, pnEdit);

                FMode = getMode();
                dao.BeginTransaction();

                if (FMode == CGlobal.FunctionMode.AddMode)
                {
                    objUser.Password = txtPassword.Text;
                    objUser.InsertByAdmin();
                }
                else if (FMode == CGlobal.FunctionMode.EditMode)
                {
                    objUser.Id = getHdf(hdfID);
                    objUser.UpdateByAdmin();
                }


                dao.EndTransaction();

                setMode(CGlobal.FunctionMode.SearchMode);
                initFuncMode();
            }

            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.CError.ErrorType err = HELPER.CError.Parse(ex.Message);
                if (err == CError.ErrorType.Duplicate)
                {
                    HELPER.Client.Alert(this, "Dữ liệu đã tồn tại!");
                }
                else
                {
                    HELPER.Client.Alert(this, "Lỗi cấp nhật CSDL!" + err.ToString());
                }
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                //Retrieves session from Login.aspx
                string fullname = (string)(Session["name"]);
                string role     = (string)(Session["role"]);
                string Email    = (string)(Session["email"]);

                //Display retrieved values from session into relevant textbox
                name.Text       = fullname;
                full_name.Text  = fullname;
                user_level.Text = role;
                email.Text      = Email;

                //Checks the role to determine what page current user can access and display it on MasterPage sidebar based on the sitemap
                if (role == "SuperAdmin")
                {
                    SiteMapDataSource1.SiteMapProvider = "Admin";
                }
                else if (role == "Executive")
                {
                    SiteMapDataSource1.SiteMapProvider = "Staff";
                }

                // Every time user visits a page
                // Get his current page name
                // And make sure he has access right
                currentPageName = GetCurrentPageName();
                DatabaseDAO userObj = new DatabaseDAO();
                hasAccess = userObj.AccessRight(role, currentPageName);
                //hasAccess = accessRight(RoleAction.roles, currentPageName);
                if (hasAccess == false)
                {
                    //CATCH ERRORS INTO ERROR LOG
                    ErrorLog.WriteErrorLog(fullname + " tried to access a prohibited site: " + currentPageName + " \r\nWith their Administrative Status of: " + role + ".");


                    // DO NOT allow user to access this page
                    html.Attributes.CssStyle.Add("display", "none");
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertUnauthorised", "alert('Unathorised Access!');window.location.href='Login.aspx';", true);
                }
            }
            catch (Exception ex)
            {
                //Catch error and write to ErrorLog.txt
                ErrorLog.WriteErrorLog(ex.ToString());
            }
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string UserID = (string)(Session["UserID"]);
                if (UserID == null)
                {
                    //If session "UserID" is equals null, means edit button event was triggered from User_Management.aspx table

                    title.InnerText = "User Management > Create User";
                    UserRegisterHeader.InnerText  = "Create Account Details";
                    User_Input_Name.Value         = "";
                    User_Input_Email.Value        = "";
                    Select_Permission_Level.Value = "";
                    User_Input_Username.Value     = "";
                }
                else
                {
                    DatabaseDAO dao  = new DatabaseDAO();
                    UserAddInfo user = new UserAddInfo();

                    //Get User data from GetData Method in DatabaseDAO
                    user = dao.GetData(UserID);
                    if (user.Name != null)
                    {
                        //If retrieved data "user.Name" is not equals null, means edit button event was triggered from User_Management.aspx table
                        //Change alert message text to updated


                        //Change title of page to Edit User
                        title.InnerText = "User Management > Edit User";
                        UserRegisterHeader.InnerText = "Update Account Details";

                        //Sets the textbox values to the values retrieved from GetData Method in DatabaseDAO
                        User_Input_Username.Value     = UserID;
                        User_Input_Email.Value        = user.Email;
                        Select_Permission_Level.Value = user.Role;
                        User_Input_Name.Value         = user.Name;
                    }
                    else
                    {
                        //If error, display failure message
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                    }
                }
            }
        }
Example #10
0
        protected void grvData_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e)
        {
            long id = long.Parse(grvData.GetRowValues(e.VisibleIndex, grvData.KeyFieldName).ToString());

            if (e.ButtonID == "GridEdit")
            {
                setHdf(hdfID, id);
                setMode(CGlobal.FunctionMode.EditMode);
                initFuncMode();
            }
            else if (e.ButtonID == "GridDelete")
            {
                DatabaseDAO dao = new DatabaseDAO();
                objProblemsTestCase = new BUS.BUS_ProblemsTestCases(dao);
                obj = new BUS.BUS_Problems(dao);

                BUS.BUS_ProblemsInContest objProblemsInContest = new BUS.BUS_ProblemsInContest(dao);

                try
                {
                    dao.BeginTransaction();

                    objProblemsTestCase.ProblemId = id;
                    objProblemsTestCase.DeleteByProblemId();
                    objProblemsInContest.DeleteByProblem(id);

                    obj.Delete(id);

                    dao.EndTransaction();
                    setMode(CGlobal.FunctionMode.SearchMode);
                    initFuncMode();
                }
                catch (Exception ex)
                {
                    dao.RollBack();
                    HELPER.CError.ErrorType err = HELPER.CError.Parse(ex.Message);
                    if (err == CError.ErrorType.InUse)
                    {
                        HELPER.Client.Alert(this, "Dữ liệu đã được sử dụng. Không thể xóa được!");
                    }
                    else
                    {
                        HELPER.Client.Alert(this, "Lỗi xóa dữ liệu!");
                    }
                }
            }
        }
Example #11
0
        protected void Login_Click(object sender, EventArgs e)
        {
            try
            {
                DatabaseDAO userObj = new DatabaseDAO();
                UserAddInfo user    = new UserAddInfo();


                // Get user Roles, Name and Email to store in session of MasterPage and
                user = userObj.GetData(User_Login.Value);
                string role = user.Role;

                string Name  = user.Name;
                string Email = user.Email;
                if (role != null || Name != null || Email != null)
                {
                    // If User information correct, let user login
                    if (role.Length > 1)
                    {
                        //Store role in session
                        Session.Add("role", role);
                        Session.Add("name", Name);
                        Session.Add("email", Email);

                        // After user successfully login
                        // Rirect to index2.aspx
                        Session["check"] = "";
                        Response.Redirect("User_Management.aspx");
                    }
                    else
                    {
                        // If User Information Wrong, display error message
                        Login_Alert.Attributes.CssStyle.Add("display", "block");
                    }
                }
                else
                {
                    // If system error, display error message through alert box
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('There seems to be a problem with the system! Contact the local Administrator');", true);
                }
            }
            catch (Exception ex)
            {
                //Catch all errors and write to ErrorLog.txt
                ErrorLog.WriteErrorLog(ex.ToString());
            }
        }
        protected void CodeTable_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //Deletes the row which the delete button event is triggered on
            DatabaseDAO dao   = new DatabaseDAO();
            int         check = dao.DeleteCode(Maintainence_Table.Rows[e.RowIndex].Cells[0].Text, Maintainence_Table.Rows[e.RowIndex].Cells[2].Text);

            //Check for exception errors in Database DAO
            if (check == 0)
            {
                //If error display error message
                ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
            }
            else
            {
                //If no error refresh page
                Response.Redirect(Request.RawUrl);
            }
        }
Example #13
0
        protected void btnSaveTestCase_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objProblemsTestCase           = new BUS.BUS_ProblemsTestCases(dao);
            objProblemsTestCase.ProblemId = getHdf(hdfID);
            dao.BeginTransaction();

            long maxPoint = long.Parse(txtMaximumPoints.Text);

            try
            {
                long sumPoin = 0;
                objProblemsTestCase.DeleteByProblemId();
                for (int i = 1; i < tbTestCase.Rows.Count; i++)
                {
                    DevExpress.Web.ASPxCheckBox ckb = (DevExpress.Web.ASPxCheckBox)tbTestCase.Rows[i].Cells[0].Controls[0];
                    DevExpress.Web.ASPxSpinEdit spn = (DevExpress.Web.ASPxSpinEdit)tbTestCase.Rows[i].Cells[1].Controls[0];
                    if (ckb.Checked)
                    {
                        objProblemsTestCase.FileName = ckb.Text;
                        objProblemsTestCase.Point    = long.Parse(spn.Value.ToString());
                        objProblemsTestCase.Insert();
                        sumPoin += objProblemsTestCase.Point;
                    }
                }
                if (sumPoin != maxPoint)
                {
                    //dao.RollBack();
                    HELPER.Client.Alert(this, "Tổng điểm các bộ test (" + sumPoin + ") không bằng số điểm tối đa (" + maxPoint + ")!");
                }

                //HELPER.Client.Alert(this, "Soos bộ test: " + tbTestCase.Rows.Count);
                dao.EndTransaction();
                // initTableTestCase();
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.Client.Alert(this, "Lỗi cập nhật bộ test: " + ex.ToString());
            }
        }
Example #14
0
        void accept(List <Object> selectItemsID)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objMyContest = new BUS.BUS_MyContest(dao);
            BUS.BUS_Notification   objNoti   = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                long acceptBy = CGlobal.GetUserID();

                if (selectItemsID.Count <= 0)
                {
                    HELPER.Client.Alert(this, "Bạn chưa chọn đơn nào!");
                }
                else
                {
                    dao.BeginTransaction();
                    long idNoti = objNoti.Insert(acceptBy, "Đã phê duyệt đơn xin vào khóa học của bạn", 3);
                    foreach (object selectItemId in selectItemsID)
                    {
                        string[] re          = selectItemId.ToString().Split('|');
                        long     idMyContest = long.Parse(re[0]);
                        long     userId      = long.Parse(re[1]);
                        objMyContest.UpdateAcepted(idMyContest, acceptBy);
                        objMyNoti.Insert(idNoti, userId);
                    }
                    dao.EndTransaction();

                    Response.Redirect(Request.RawUrl, false);
                }
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.Client.Alert(this, "Lỗi cập nhật CSDL! " + ex.Message);
            }
        }
Example #15
0
        void clickMulti(int clickType)
        {
            List <Object> selectItemsID = new List <object>();

            selectItemsID = grvData.GetSelectedFieldValues(grvData.KeyFieldName);
            DatabaseDAO dao = new DatabaseDAO();

            objUser = new BUS.BUS_Users(dao);
            BUS.BUS_Notification   objNoti   = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                long acceptBy = CGlobal.GetUserID();

                if (selectItemsID.Count <= 0)
                {
                    HELPER.Client.Alert(this, "Bạn chưa chọn người dùng nào!");
                }
                else
                {
                    long idNoti = 0;
                    switch (clickType)
                    {
                    case 1:     // del , xóa
                        break;

                    case 2:     // accept, kích hoạt
                        idNoti = objNoti.Insert(acceptBy, "Đã kích hoạt tài khoản của bạn", 3);
                        break;

                    case 3:     // un accept, bỏ kích hoạt
                        break;

                    case 4:     // to Usertype 1, sinh viên
                        idNoti = objNoti.Insert(acceptBy, "Đã chuyển tài khoản của bạn thành tài khoản Sinh Viên", 3);
                        break;

                    case 5:     // to Usertype 2. Giáo viên
                        idNoti = objNoti.Insert(acceptBy, "Đã chuyển tài khoản của bạn thành tài khoản Giáo Viên", 3);
                        break;

                    default:
                        break;
                    }

                    foreach (object selectItemId in selectItemsID)
                    {
                        long userId = long.Parse(selectItemId.ToString());

                        switch (clickType)
                        {
                        case 1:     // del , xóa
                            objUser.Delete(userId);

                            break;

                        case 2:     // accept, kích hoạt
                            objUser.UpdateByAdminEnable(userId, 1);
                            objMyNoti.Insert(idNoti, userId);
                            break;

                        case 3:     // un accept, bỏ kích hoạt
                            objUser.UpdateByAdminEnable(userId, 0);
                            break;

                        case 4:     // to Usertype 1, sinh viên
                            objUser.UpdateByAdminType(userId, 1);
                            objMyNoti.Insert(idNoti, userId);
                            break;

                        case 5:     // to Usertype 2. Giáo viên
                            objUser.UpdateByAdminType(userId, 2);
                            objMyNoti.Insert(idNoti, userId);
                            break;

                        default:
                            break;
                        }
                    }

                    Response.Redirect(Request.RawUrl, false);
                }
            }
            catch (Exception ex)
            {
                HELPER.Client.Alert(this, "Lỗi cập nhật CSDL! " + ex.Message);
            }
        }
Example #16
0
 public BUS_Submission(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #17
0
        public async Task <RespuestaProceso> CrearBaseDeDatos()
        {
            RespuestaProceso respuesta = new RespuestaProceso();

            respuesta.ProcesadoCorrectamente = true;

            List <Type> tablasRequeridas = new List <Type>();

            //Se verifica si el usuario debe tener base de datos local
            tablasRequeridas.Add(typeof(Entities.Operaciones.Agencia));

            if (ParametrosSistema.PermisosUsuarioAlmacenado.Count(p => p.NombreOpcion.ToLower() == "registrar_evento_logistico" || p.NombreOpcion.ToLower() == "eventoslogisticosterceros") > 0)
            {
                tablasRequeridas.Add(typeof(Entities.Operaciones.TipoEventoLogistico));
                tablasRequeridas.Add(typeof(Entities.Operaciones.EventoLogistico));
                tablasRequeridas.Add(typeof(Entities.Operaciones.CampoEventoLogistico));
                tablasRequeridas.Add(typeof(Entities.Operaciones.ItemCampoEventoLogistico));
                tablasRequeridas.Add(typeof(Entities.Operaciones.SubItemCampoEventoLogistico));
                tablasRequeridas.Add(typeof(Entities.Operaciones.JerarquiaTipoEventoLogistico));
                //tablasRequeridas.Add(typeof(Entities.Operaciones.RemesasPorNumeroEntrega));

                tablasRequeridas.Add(typeof(Entities.Operaciones.HistorialActivacionManifiesto));
                tablasRequeridas.Add(typeof(Entities.Comercial.Entrega));

                tablasRequeridas.Add(typeof(Entities.IT.ConfiguracionApp));
            }
            if (tablasRequeridas.Count > 0)
            {
                DatabaseDAO dao     = new DatabaseDAO();
                bool        esNueva = false;
                if (!DependencyService.Get <ISQLite>().ExisteBaseDeDatos() || true)
                {
                    dao.CrearBaseDeDatos(tablasRequeridas);
                    esNueva = true;
                }
                if (esNueva)
                {
                    if (await Common.ParametrosSistema.isOnline)
                    {
                        try
                        {
                            //Se llenan las tablas maestras
                            EventoLogisticoBLL eventoBLL = new EventoLogisticoBLL();

                            bool?aplicaTerceros = null;
                            if (ParametrosSistema.PermisosUsuarioAlmacenado.Count(p => p.NombreOpcion.ToLower() == "eventoslogisticosterceros") > 0)
                            {
                                aplicaTerceros = true;
                            }
                            foreach (Type tabla in tablasRequeridas)
                            {
                                switch (tabla.Name)
                                {
                                case "TipoEventoLogistico":
                                    var tiposEventos = await eventoBLL.SeleccionarTiposEventoLogistico(consultaLocal : false, aplicaTerceros : aplicaTerceros);

                                    dao.GuardarRegistros(tiposEventos);
                                    break;

                                case "EventoLogistico":
                                    if (!String.IsNullOrEmpty(ParametrosSistema.UsuarioActual))
                                    {
                                        //Se consultan los ultimos eventos del usuario actual
                                        var eventos = await eventoBLL.SeleccionarEventosLogisticosUsuarioActual();

                                        if (eventos != null)
                                        {
                                            dao.GuardarRegistros(eventos);
                                        }
                                    }
                                    break;

                                case "CampoEventoLogistico":
                                    var camposTiposEventos = await eventoBLL.SeleccionarCamposPorEvento(null, consultaLocal : false);

                                    dao.GuardarRegistros(camposTiposEventos);
                                    break;

                                case "ItemCampoEventoLogistico":
                                    var itemsCampoEventoLogistico = await eventoBLL.SeleccionarItemsPorCamposEvento(null, null, consultaLocal : false);

                                    dao.GuardarRegistros(itemsCampoEventoLogistico);
                                    break;

                                case "SubItemCampoEventoLogistico":
                                    var subItemsCampoEventoLogistico = await eventoBLL.SeleccionarSubItemsPorCamposEvento(null, consultaLocal : false);

                                    dao.GuardarRegistros(subItemsCampoEventoLogistico);
                                    break;

                                case "JerarquiaTipoEventoLogistico":
                                    var jerarquiaTiposEventosLogisticos = await eventoBLL.SeleccionarJerarquiaTipoEventosLogisticos(consultaLocal : false, aplicaTerceros : aplicaTerceros);

                                    dao.GuardarRegistros(jerarquiaTiposEventosLogisticos);
                                    break;

                                case "HistorialActivacionManifiesto":
                                    var transportes = await eventoBLL.SeleccionarTransporteHabilitadoRegistroEventos(consultaLocal : false, tercero : aplicaTerceros);

                                    if (transportes != null && transportes.Count > 0)
                                    {
                                        Transporte transporte = transportes[0];

                                        HistorialActivacionManifiesto historial = new HistorialActivacionManifiesto();
                                        historial.Activo             = true;
                                        historial.FechaActivacion    = DateTime.Now;
                                        historial.NumeroManifiesto   = transporte.NumeroTransporte;
                                        historial.Placa              = transporte.Placa;
                                        historial.NumeroDocConductor = transporte.NumeroDocConductor.ToString();
                                        historial.NombreRuta         = transporte.NombreRuta;
                                        historial.UsuarioActivacion  = ParametrosSistema.UsuarioActual;

                                        //Se busca localmente el evento de activación del transporte activo
                                        var eventosActivacionTransporte = eventoBLL.SeleccionarEventosLogisticos(transporte.NumeroTransporte, codigoTipoEvento: (int)TipoEventoLogisticoEnum.ActivarViaje, consultaLocal: true);
                                        if (eventosActivacionTransporte != null & eventosActivacionTransporte.Count > 0)
                                        {
                                            historial.FechaActivacion = eventosActivacionTransporte[0].FechaEvento;
                                        }

                                        HistorialActivacionManifiestoDAO historialActivacionDAO = new HistorialActivacionManifiestoDAO();
                                        historialActivacionDAO.GuardarHistorialActivacionManifiesto(historial);

                                        //Se guardan las entregas del transporte
                                        if (transporte.Entregas != null && transporte.Entregas.Count > 0)
                                        {
                                            EntregaBLL entregaBLL = new EntregaBLL();
                                            foreach (Entrega entrega in transporte.Entregas)
                                            {
                                                entregaBLL.GuardarEntrega(entrega);
                                            }
                                        }
                                    }
                                    break;

                                case "Agencia":
                                    List <Agencia> agencias = new List <Agencia>();
                                    agencias = CargarAgencias();
                                    dao.GuardarRegistros(agencias);
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            respuesta.ProcesadoCorrectamente = false;
                            respuesta.Respuesta = "Ocurrió un error configurando la aplicación.";
                        }
                    }
                    else
                    {
                        respuesta.ProcesadoCorrectamente = false;
                        respuesta.Respuesta = "Se necesita una conexión a Internet para que la aplicación pueda configurarse correctamente. Esto sólo se necesita la primera vez.";
                    }
                }
            }



            return(respuesta);
        }
Example #18
0
 public BUS_Notification(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #19
0
 public BUS_MyContest(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #20
0
 public BUS_Compiler(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #21
0
 public BUS_Contests(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #22
0
 public BUS_Users(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
 public BUS_ProblemsInContest(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #24
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            IsBusy = true;
            btnVerDocumentos.IsVisible = true;
            //activityIndicator.IsRunning = true;
            //activityIndicator.IsVisible = true;

            //********************************************** CREAR TABLA HISTORIALACTIVACION MANIFIESTO *******************************************//
            DatabaseDAO        dao       = new DatabaseDAO();
            EventoLogisticoBLL eventoBLL = new EventoLogisticoBLL();

            if (await ParametrosSistema.isOnline)
            {
                using (var db = DependencyService.Get <ISQLite>().GetConnection())
                {
                    db.DropTable <HistorialActivacionManifiesto>();
                    db.DropTable <Entrega>();
                    db.CreateTable(typeof(Entities.Operaciones.HistorialActivacionManifiesto));
                    db.CreateTable(typeof(Entities.Comercial.Entrega));
                }

                bool?aplicaTerceros = null;
                if (ParametrosSistema.PermisosUsuarioAlmacenado.Count(p => p.NombreOpcion.ToLower() == "eventoslogisticosterceros") > 0)
                {
                    aplicaTerceros = true;
                }


                var transportes = await eventoBLL.SeleccionarTransporteHabilitadoRegistroEventos(consultaLocal : false, tercero : aplicaTerceros);

                if (transportes != null && transportes.Count > 0)
                {
                    Transporte transporte = transportes[0];

                    HistorialActivacionManifiesto historial = new HistorialActivacionManifiesto();
                    historial.Activo             = true;
                    historial.FechaActivacion    = DateTime.Now;
                    historial.NumeroManifiesto   = transporte.NumeroTransporte;
                    historial.Placa              = transporte.Placa;
                    historial.NumeroDocConductor = transporte.NumeroDocConductor.ToString();
                    historial.NombreRuta         = transporte.NombreRuta;
                    historial.UsuarioActivacion  = ParametrosSistema.UsuarioActual;

                    //Se busca localmente el evento de activación del transporte activo
                    var eventosActivacionTransporte = eventoBLL.SeleccionarEventosLogisticos(transporte.NumeroTransporte, codigoTipoEvento: (int)TipoEventoLogisticoEnum.ActivarViaje, consultaLocal: true);
                    if (eventosActivacionTransporte != null & eventosActivacionTransporte.Count > 0)
                    {
                        historial.FechaActivacion = eventosActivacionTransporte[0].FechaEvento;
                    }


                    HistorialActivacionManifiestoDAO historialActivacionDAO = new HistorialActivacionManifiestoDAO();
                    historialActivacionDAO.GuardarHistorialActivacionManifiesto(historial);

                    //Se guardan las entregas del transporte
                    if (transporte.Entregas != null && transporte.Entregas.Count > 0)
                    {
                        EntregaBLL entregaBLL = new EntregaBLL();
                        foreach (Entrega entrega in transporte.Entregas)
                        {
                            try
                            {
                                entregaBLL.GuardarEntrega(entrega);
                            }
                            catch (Exception ex)
                            {
                                DisplayAlert("Error", ex.Message, "Aceptar");
                            }
                        }
                    }
                }
            }

            //********************************************** FIN CREAR TABLA HISTORIALACTIVACION MANIFIESTO *******************************************//

            //EventoLogisticoBLL eventoBLL = new EventoLogisticoBLL();
            var tiposEventos = new List <TipoEventoLogistico>();

            //Se verifica si hay eventos pendientes por sincronizar
            var eventosPendientes = eventoBLL.SeleccionarEventosPendientesSincronizar();

            if (eventosPendientes != null && eventosPendientes.Count > 0 && await ParametrosSistema.isOnline)
            {
                IsBusy = false;
                await DisplayAlert("Atención", "No puede registrar nuevos eventos porque tiene " + eventosPendientes.Count + "  eventos pendientes por sincronizar. Debe ir al menú 'Sincronización' para realizar la sincronización manualmente.", "Aceptar");
            }
            else
            {
                Util util    = new Util();
                bool?tercero = null;
                if (util.UsuarioTienePermiso("eventoslogisticosterceros"))
                {
                    tercero = true;
                }

                List <Transporte> transportesHabilitadosRegistroEventos = new List <Transporte>();
                transportesHabilitadosRegistroEventos = await eventoBLL.SeleccionarTransporteHabilitadoRegistroEventos(!await ParametrosSistema.isOnline, tercero);

                if (transportesHabilitadosRegistroEventos != null && transportesHabilitadosRegistroEventos.Count > 0)
                {
                    viajeActivo = transportesHabilitadosRegistroEventos[0];
                }

                if (viajeActivo == null && tercero == true)
                {
                    DisplayAlert("Alerta", "Ud no posee un viaje activo, por lo tando no puede registrar eventos.", "Aceptar");
                    await Navigation.PushAsync(new HomeView());
                }
                else
                {
                    if (tercero.HasValue && tercero.Value)
                    {
                        if (viajeActivo != null)
                        {
                            try
                            {
                                tiposEventos = await eventoBLL.SeleccionarSiguienteEventoporManifiesto(viajeActivo.NumeroTransporte, consultaLocal : !await ParametrosSistema.isOnline);

                                lblNumeroViajeActivo.Text = viajeActivo.NumeroTransporte.ToString();
                                lblRuta.Text = viajeActivo.NombreRuta;
                            }
                            catch (Exception ex)
                            {
                                DisplayAlert("Alerta", "Ha ocurrido un inconveniente, por favor ingrese nuevamente.", "Aceptar");
                            }
                        }
                        else
                        {
                            tiposEventos = await eventoBLL.SeleccionarSiguienteEventoporManifiesto(0, consultaLocal : !await ParametrosSistema.isOnline);

                            lblNumeroViajeActivo.Text      = "Sin viaje activo";
                            lblNumeroViajeActivo.TextColor = Color.Red;
                            btnVerDocumentos.IsVisible     = false;
                        }
                    }
                    else
                    {
                        TransporteBLL transporteBLL             = new TransporteBLL();
                        HistorialActivacionManifiesto historial = transporteBLL.SeleccionarHistorialManifiestoActivoPorConductor(ParametrosSistema.NumeroIdentificacionUsuarioActual);

                        if (historial != null)
                        {
                            tiposEventos = await eventoBLL.SeleccionarSiguienteEventoporManifiesto(historial.NumeroManifiesto, consultaLocal : !await ParametrosSistema.isOnline);

                            lblNumeroViajeActivo.Text = historial.NumeroManifiesto.ToString();
                            lblRuta.Text = historial.NombreRuta;
                        }
                        else
                        {
                            tiposEventos = await eventoBLL.SeleccionarSiguienteEventoporManifiesto(0, consultaLocal : !await ParametrosSistema.isOnline);

                            lblNumeroViajeActivo.Text      = "Sin viaje activo";
                            lblNumeroViajeActivo.TextColor = Color.Red;
                            btnVerDocumentos.IsVisible     = false;
                        }
                    }
                    //var dataTemplate = new DataTemplate(typeof(TextCell));
                    //dataTemplate.SetBinding(TextCell.TextProperty, "NombreEvento");


                    lvMenuEventos.ItemsSource = tiposEventos;
                    //lvMenuEventos.ItemTemplate = dataTemplate;

                    IsBusy = false;
                    //activityIndicator.IsRunning = false;
                    //activityIndicator.IsVisible = false;
                }
            }
        }
Example #25
0
 public BUS_M_LOOKUP(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #26
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objContest       = new BUS.BUS_Contests(dao);
            objProbInContest = new BUS.BUS_ProblemsInContest(dao);

            try
            {
                dao.BeginTransaction();
                HELPER.CWebPage.BindProperty(objContest, pnEdit);
                try
                {
                    //objContest.StartTime = objContest.StartTime.Date.AddMinutes(txtStartTime.DateTime.TimeOfDay.TotalMinutes);
                    //objContest.EndTime = objContest.EndTime.Date.AddMinutes(txtEndTime.DateTime.TimeOfDay.TotalMinutes);

                    if (txtIsLimitTime.Checked)
                    {
                        objContest.StartTime = dteStartTime.Date.AddMinutes(txtStartTime.DateTime.TimeOfDay.TotalMinutes);
                        objContest.EndTime   = dteEndTime.Date.AddMinutes(txtEndTime.DateTime.TimeOfDay.TotalMinutes);

                        if (objContest.StartTime > objContest.EndTime)
                        {
                            HELPER.Client.Alert(this, "Thời gian bắt đầu phải trước thời gian kết thúc!");
                            return;
                        }
                    }
                    else
                    {
                        objContest.StartTime = DateTime.MinValue;
                        objContest.EndTime   = DateTime.MinValue;
                    }
                }
                catch (Exception)
                {
                    objContest.StartTime = DateTime.MinValue;
                    objContest.EndTime   = DateTime.MinValue;
                }

                FMode = getMode();

                long id = 0;
                if (FMode == CGlobal.FunctionMode.AddMode)
                {
                    id = objContest.Insert();
                    setHdf(hdfID, id);
                    objProbInContest.ContestsId = id;
                }
                else if (FMode == CGlobal.FunctionMode.EditMode)
                {
                    id            = getHdf(hdfID);
                    objContest.Id = id;
                    objProbInContest.ContestsId = id;

                    objContest.Update();
                    objProbInContest.DeleteByContest();
                }

                DataTable      dtChecked = objProbInContest.LoadByContestID(id);
                List <DataRow> list      = dtChecked.AsEnumerable().ToList();

                foreach (ListEditItem item in cblProblems.Items)
                {
                    if (item.Selected)
                    {
                        objProbInContest.ProblemsId = long.Parse(item.Value.ToString());
                        objProbInContest.Insert();
                    }
                }
                dao.EndTransaction();

                setMode(CGlobal.FunctionMode.SearchMode);
                initFuncMode();
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.CError.ErrorType err = HELPER.CError.Parse(ex.Message);
                if (err == CError.ErrorType.Duplicate)
                {
                    HELPER.Client.Alert(this, "Dữ liệu đã tồn tại!");
                }
                else
                {
                    HELPER.Client.Alert(this, "Lỗi cấp nhật CSDL!" + err.ToString());
                }
            }
        }
Example #27
0
 public BUS_ProblemsTestCases(DatabaseDAO _dao)
 {
     this.dao = _dao;
 }
Example #28
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objNoti = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                dao.BeginTransaction();
                HELPER.CWebPage.BindProperty(objNoti, pnEdit);
                objNoti.NotiType = int.Parse(cboNotiType.Value.ToString());
                FMode            = getMode();

                long NotiID = 0;
                if (FMode == CGlobal.FunctionMode.AddMode)
                {
                    NotiID = objNoti.Insert();
                    setHdf(hdfID, NotiID);
                    objMyNoti.NotificationID = NotiID;
                    switch (objNoti.NotiType)
                    {
                    case 1:    //khoa hoc
                        foreach (ListEditItem item in cblContestID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.ContestID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    case 2:    //bt
                        foreach (ListEditItem item in cblProblemID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.ProblemID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    case 3:     // user
                        foreach (ListEditItem item in cblUserID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.UserID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    default:
                        throw new Exception("Chọn loại thông báo!");
                        break;
                    }
                }


                dao.EndTransaction();

                setMode(CGlobal.FunctionMode.SearchMode);
                initFuncMode();
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.CError.ErrorType err = HELPER.CError.Parse(ex.Message);
                if (err == CError.ErrorType.Duplicate)
                {
                    HELPER.Client.Alert(this, "Dữ liệu đã tồn tại!");
                }
                else
                {
                    HELPER.Client.Alert(this, "Lỗi cấp nhật CSDL!" + err.ToString());
                }
            }
        }