Exemple #1
0
        /// <summary>
        /// Sets the patient to status handled.
        /// </summary>
        /// <param name="patient">The patient.</param>
        /// <exception cref="QNomy.SQL.Exceptions.GeneralDbException">
        /// </exception>
        public async Task SetPatientHandled(IPatient patient)
        {
            try
            {
                var currentPatient = await this.dbContext.Patients.FindAsync(patient.TicketNumber);

                if (currentPatient == null)
                {
                    throw new GeneralDbException(ApplicationMessages.PatientIsNotFound(patient));
                }

                currentPatient.Handled = true;

                this.dbContext.Patients.Update(currentPatient);

                await this.dbContext.SaveChangesAsync();
            }
            catch (GeneralDbException expDb)
            {
                // It was thrown above in 'not found scenario'
                throw;
            }
            catch (Exception exp)
            {
                throw new GeneralDbException(ApplicationMessages.GeneralDbExceptionMessage(), exp);
            }
        }
        public DataSet GetCustomDataSet(string procedureName, IGenericEntity ent)
        {
            storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey(procedureName))
            {
                throw new NotImplementedException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_IMPLEMENT, procedureName));
            }

            DBStoredProcedure insertSP = storedProcedures[procedureName];
            SqlCommand        cmd      = insertSP.GetSqlCommand();

            DataSet returnDS = null;

            try
            {
                returnDS = CurrentConnectionManager.GetDataSet(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return(returnDS);
        }
Exemple #3
0
 protected override void OnInit(EventArgs e)
 {
     try
     {
         if (String.IsNullOrEmpty(_PopUpName))
         {
             throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_MUST_SET_POPUPNAME_FOR_CONTROL, this.UniqueID));
         }
         if (_PopUpWidth == 0)
         {
             throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_MUST_SET_POPUPWIDTH_FOR_CONTROL, this.UniqueID));
         }
         if (_PopUpHeight == 0)
         {
             throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_MUST_SET_POPUPHEIGHT_FOR_CONTROL, this.UniqueID));
         }
         btnPopUp.Attributes.Add("onclick", "");
         base.OnInit(e);
     }
     catch (IndException ex)
     {
         ControlHierarchyManager.ReportError(ex);
         return;
     }
     catch (Exception ex)
     {
         ControlHierarchyManager.ReportError(new IndException(ex));
         return;
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //Verify that the import parameter exits
            if (String.IsNullOrEmpty(this.Request.QueryString["IdImport"].ToString()))
            {
                throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_COULD_NOT_GET_PARAMETER, "IdImport"));
            }
            //Get the Import Id parameter
            idImport = int.Parse(this.Request.QueryString["IdImport"].ToString());

            if (!IsPostBack)
            {
                DsLogs = null;
            }

            //Loads the data
            LoadEditableGrid();
            LoadHeader();
        }
        catch (IndException ex)
        {
            ShowError(ex);
            return;
        }
        catch (Exception ex)
        {
            ShowError(new IndException(ex));
            return;
        }
    }
        /// <summary>
        /// Executes a custom stored procedure and returns the SP return value
        /// </summary>
        /// <param name="procedureName"></param>
        /// <param name="ent"></param>
        /// <returns>the stored procedure returned value</returns>
        public int ExecuteCustomProcedureWithReturnValue(string procedureName, IGenericEntity ent)
        {
            storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey(procedureName))
            {
                throw new NotImplementedException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_IMPLEMENT, procedureName));
            }

            DBStoredProcedure insertSP        = storedProcedures[procedureName];
            SqlCommand        cmd             = insertSP.GetSqlCommand();
            SqlParameter      returnParameter = cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);

            returnParameter.Direction = ParameterDirection.ReturnValue;

            try
            {
                CurrentConnectionManager.ExecuteStoredProcedure(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return((int)cmd.Parameters["RETURN_VALUE"].Value);
        }
        /// <summary>
        /// xecutes a custom stored procedure and returns the number of rows affected
        /// </summary>
        /// <param name="procedureName"></param>
        /// <param name="ent"></param>
        /// <returns>the number of rows affected</returns>
        public int ExecuteCustomProcedure(string procedureName, IGenericEntity ent)
        {
            int rowsAffected;

            storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey(procedureName))
            {
                throw new NotImplementedException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_IMPLEMENT, procedureName));
            }

            DBStoredProcedure insertSP = storedProcedures[procedureName];
            SqlCommand        cmd      = insertSP.GetSqlCommand();

            try
            {
                rowsAffected = CurrentConnectionManager.ExecuteStoredProcedure(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return(rowsAffected);
        }
Exemple #7
0
        private bool SendInternal(ApplicationMessages messageType, byte[] messageData)
        {
            var header = new EnttecMessageHeader();

            header.SetMessageType(messageType);
            header.SetDataLength(messageData.Length);
            if (!header.IsValid())
            {
                throw new ArgumentException("Invalid message data!");
            }
            if (!_ftdiDriver.Write(header.Data))
            {
                return(false);
            }

            var body = new EnttecMessageBody(messageData);

            if (!_ftdiDriver.Write(body.Data))
            {
                return(false);
            }

            var footer = new EnttecMessageFooter();

            if (!_ftdiDriver.Write(footer.Data))
            {
                return(false);
            }

            return(true);
        }
        public ActionResult Settings(int?id, FormCollection form, ClientSettings clientSettings)
        {
            if (Roles.IsUserInRole("SuperAdmin") && Session["ClientId"] != null)
            {
                if (!ModelState.IsValid)
                {
                    ApplicationMessages msg = new ApplicationMessages("Invalid entry.", MessageType.Error);
                    ViewData["Message"] = msg;
                    return(View(clientSettings));
                }
                clientSettings.ClientId = (int)Session["ClientId"];

                if (ClientModels.SaveClientSettings(clientSettings) > 0)
                {
                    ApplicationMessages msg = new ApplicationMessages("Settings Saved", MessageType.Success);
                    ViewData["Message"] = msg;
                }
                return(View(clientSettings));
            }
            else
            {
                ApplicationMessages msg = new ApplicationMessages("You are not authorize to update Settings.", MessageType.Error);
                ViewData["Message"] = msg;
                return(View(clientSettings));
            }
        }
Exemple #9
0
        /// <summary>
        /// This method returns the exchange rate from the base based on to parameters: Currency and
        /// YearMonth; To be known that inside stored procedure two other rules for selecting this ExchangeRate
        /// are used. For more information look after Stored Procedure bgtSelectExchangeRateForConverter
        /// </summary>
        /// <param name="exchangeRate"></param>
        /// <returns></returns>
        internal decimal GetExchangeRate(BudgetExchangeRate exchangeRate)
        {
            _CurrencyFrom = exchangeRate.CurrencyFrom;
            _CurrencyTo   = exchangeRate.CurrencyTo;
            _YearMonth    = exchangeRate.YearMonth;

            DBExchangeRateReader dbc = new DBExchangeRateReader(this.CurrentConnectionManager);

            //If for a random reason the specified cast cannot be made, an IndException is thrown
            try
            {
                object returnedER = dbc.ExecuteScalar("bgtSelectExchangeRateForConverter", this);
                //TODO: Modifiy error message - use names instead of ids
                if (returnedER == DBNull.Value)
                {
                    throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_EXCHANGE_RATE_NOT_FOUND, exchangeRate.CurrencyFrom.ToString(), exchangeRate.CurrencyTo.ToString()));
                }
                ExchangeRate = (decimal)returnedER;
            }
            catch (Exception exc)
            {
                throw new IndException(exc);
            }
            return(ExchangeRate);
        }
Exemple #10
0
        public void AddParameter(DBParameter dbParameter)
        {
            if (DBParameters.ContainsKey(dbParameter.Name))
            {
                throw new Exception(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_PROCEDURE_ALREADY_CONTAINS_PARAMETER, ProcedureName, dbParameter.Name));
            }

            DBParameters.Add(dbParameter.Name, dbParameter);
        }
        public ActionResult Edit(FormCollection form, Employees newEmp)
        {
            ViewData["EmployeeRanks"] = Utilities.GetEmployeeRankNameList();
            if (Session["ClientId"] != null)
            {
                newEmp.ClientId = (int)Session["ClientId"];
                // if (Session["BranchId"] != null)
                //     newEmp.BranchId = (int)Session["BranchId"];

                ViewData["Branchs"] = Utilities.GetBranchNameList((int)Session["ClientId"]);
                if (Session["ZoneId"] != null)
                {
                    ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], (int)Session["ZoneId"]);
                }
                else
                {
                    ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], null);
                }

                ViewData["Zones"] = Utilities.GetZoneNameList((int)Session["ClientId"]);
            }
            else
            {
                if (Roles.IsUserInRole("SuperAdmin"))
                {
                    return(RedirectToAction("List", "Client"));
                }
            }
            ViewData["Genders"]        = Utilities.GetGenderNameList();
            ViewData["MaritalStstus"]  = Utilities.GetMaritalStatusList();
            ViewData["Qualifications"] = Utilities.GetQualificationList();
            ViewData["States"]         = Utilities.GetStateList(Utilities.IndiaCountryCode);
            ViewData["Countries"]      = Utilities.GetCountryList();

            if (!ModelState.IsValid)
            {
                //ModelState.AddModelError("error", "Employee Id already exists");
                ApplicationMessages msg = new ApplicationMessages("Invalid entry.", MessageType.Error);
                ViewData["Message"] = msg;
                return(View());
            }

            int result = EmployeeModels.UpdateEmployee(newEmp);

            if (result > 0)
            {
                ApplicationMessages msg = new ApplicationMessages("Employee details updated successfully.", MessageType.Success);
                ViewData["Message"] = msg;
            }
            else
            {
                ApplicationMessages msg = new ApplicationMessages("Failed to update. Please try again.", MessageType.Faild);
                ViewData["Message"] = msg;
            }
            return(View());
        }
 /// <summary>
 /// Builds a new object based on a given string value
 /// </summary>
 /// <param name="value">The string value of the YearMonth</param>
 public YearMonth(string value)
 {
     if (string.IsNullOrEmpty(value))
     {
         throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_NULL_ENCOUNTERED, "YearMonth"));
     }
     if (!int.TryParse(value, out _Value))
     {
         throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FORMAT_NOT_VALID, "YearMonth"));
     }
 }
Exemple #13
0
        public bool GetMessageType(out ApplicationMessages messageType)
        {
            var mType = Data[1];

            messageType = (ApplicationMessages)mType;
            if (Enum.IsDefined(typeof(ApplicationMessages), mType) && mType != (byte)ApplicationMessages.Unknown)
            {
                return(true);
            }

            return(false);
        }
        public async Task <ActionResult <ApplicationMessages> > GetApplicationMessagesAsync(int rollNumber)
        {
            var messSubject = await _context.Message_Subject.Where(a => a.RollNumber == rollNumber)
                              .Include(m => m.Message_Chain)
                              .ToListAsync();

            ApplicationMessages allAppAndMessage = new ApplicationMessages();

            allAppAndMessage.Message_Subjects = messSubject;

            return(allAppAndMessage);
        }
Exemple #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //If the page is not posted back, populate the controls on it with other costs data
         if (!IsPostBack)
         {
             if (String.IsNullOrEmpty(this.Request.QueryString["IsAssociateCurrency"]))
             {
                 throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_COULD_NOT_GET_PARAMETER, "IsAssociateCurrency"));
             }
             if (this.Request.QueryString["IsAssociateCurrency"] != "0" && this.Request.QueryString["IsAssociateCurrency"] != "1")
             {
                 throw new IndException(ApplicationMessages.EXCEPTION_WRONG_ASSOCIATE_CURRENCY_PARAMETER);
             }
             if (String.IsNullOrEmpty(this.Request.QueryString["AmountScaleOption"]))
             {
                 throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_COULD_NOT_GET_PARAMETER, "AmountScaleOption"));
             }
             RevisedBudgetOtherCosts otherCosts = (RevisedBudgetOtherCosts)SessionManager.GetSessionValueRedirect(this, SessionStrings.REVISED_OTHER_COSTS);
             //If other costs is null, the redirect does not take place immediately
             if (otherCosts != null)
             {
                 //initialize controls to empty string before loading from database
                 InitializePopupControls();
                 RevisedBudgetOtherCosts existingOtherCosts = SessionManager.GetRevisedOtherCost(this, otherCosts);
                 if (existingOtherCosts == null)
                 {
                     otherCosts.IsAssociateCurrency = this.Request.QueryString["IsAssociateCurrency"] == "1" ? true : false;
                     DataSet dsOtherCosts = otherCosts.GetAll(true);
                     PopulateControls(dsOtherCosts.Tables[0]);
                 }
                 else
                 {
                     PopulateControls(existingOtherCosts);
                 }
             }
         }
     }
     catch (IndException exc)
     {
         ShowError(exc);
         return;
     }
     catch (Exception exc)
     {
         ShowError(new IndException(exc));
         return;
     }
 }
Exemple #16
0
        private void InitializeWithExceptionOnError(Hashtable values)
        {
            if (values["TotalHours"] != null)
            {
                //Verify that the values are of permitted type/range
                if (int.TryParse(conversionUtils.RemoveThousandsFormat(values["TotalHours"].ToString()), out this._TotalHours) == false)
                {
                    throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_NOT_NUMERIC, "Total Hours"));
                }

                if (this._TotalHours < 0)
                {
                    throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_MUST_BE_POSITIVE, "Total Hours"));
                }
            }
            else
            {
                this._TotalHours = ApplicationConstants.INT_NULL_VALUE_FOR_VALUE_FIELDS;
            }

            if (values["ValuedHours"] != null)
            {
                if (decimal.TryParse(conversionUtils.RemoveThousandsFormat(values["ValuedHours"].ToString()), out this._ValuedHours) == false)
                {
                    throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_NOT_NUMERIC, "Valued Hours"));
                }

                if (this._ValuedHours < 0)
                {
                    throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_MUST_BE_POSITIVE, "Valued Hours"));
                }
            }
            else
            {
                this._ValuedHours = ApplicationConstants.DECIMAL_NULL_VALUE;
            }

            if (values["Sales"] != null)
            {
                if (decimal.TryParse(conversionUtils.RemoveThousandsFormat(values["Sales"].ToString()), out this._Sales) == false)
                {
                    throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_NOT_NUMERIC, "Sales"));
                }
            }
            else
            {
                this._Sales = ApplicationConstants.DECIMAL_NULL_VALUE;
            }
        }
Exemple #17
0
        /// <summary>
        /// Adds the patient.
        /// </summary>
        /// <param name="patient">The patient.</param>
        /// <returns></returns>
        /// <exception cref="QNomy.SQL.Exceptions.GeneralDbException"></exception>
        public async Task <IPatient> AddPatient(IPatient patient)
        {
            try
            {
                var result = await this.dbContext.Patients.AddAsync(patient as Patient);

                await this.dbContext.SaveChangesAsync();

                return(result.Entity);
            }
            catch (Exception exp)
            {
                throw new GeneralDbException(ApplicationMessages.GeneralDbExceptionMessage(), exp);
            }
        }
Exemple #18
0
    private int GetMultiplier()
    {
        if (String.IsNullOrEmpty(this.Request.QueryString["AmountScaleOption"]))
        {
            throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_COULD_NOT_GET_PARAMETER, "AmountScaleOption"));
        }
        AmountScaleOption amountScaleOption = BudgetUtils.GetAmountScaleOptionFromText(this.Request.QueryString["AmountScaleOption"]);
        int multiplier = 1;

        for (int i = 1; i <= (int)amountScaleOption; i++)
        {
            multiplier *= 1000;
        }
        return(multiplier);
    }
Exemple #19
0
        public byte[] CreateMessage(ApplicationMessages messageType, byte[] messageData)
        {
            var header = new EnttecMessageHeader();

            header.SetMessageType(messageType);
            header.SetDataLength(messageData.Length);
            var body   = new EnttecMessageBody(messageData);
            var footer = new EnttecMessageFooter();

            if (!header.IsValid() || !footer.IsValid())
            {
                throw new ArgumentException("Invalid message data!");
            }

            return(CreateMessageFromParts(header, body, footer));
        }
Exemple #20
0
        /// <summary>
        /// Gets all patients.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="GeneralDbException"></exception>
        public async Task <IEnumerable <IPatient> > GetAllPatients(int pageIndex = 1, int pageSize = 10)
        {
            try
            {
                var result = await this.dbContext.Patients.ActualPatients()
                             .Skip((pageIndex - 1) * pageSize)
                             .Take(pageSize)
                             .ToListAsync();

                return(result.AssureNotNull());
            }
            catch (Exception ex)
            {
                throw new GeneralDbException(ApplicationMessages.GeneralDbExceptionMessage(), ex);
            }
        }
Exemple #21
0
        public ActionResult Create(FormCollection collection, Clients client, HttpPostedFileBase agentPhoto)
        {
            ViewData["CountryList"]      = Utilities.GetCountryList();
            ViewData["StateList"]        = Utilities.GetStateList(null);
            ViewData["BusinessTypeList"] = Utilities.GetBusinessTypeList();
            try
            {
                if (!ModelState.IsValid)
                {
                    ApplicationMessages msg = new ApplicationMessages("Invalid entry.", MessageType.Error);

                    ViewData["Message"] = msg;
                    return(View());
                }
                // TODO: Add insert logic here
                if (client != null)
                {
                    client.LastUpdated    = DateTime.Now;
                    client.AdminstratorId = 1;
                }
                if (agentPhoto != null)
                {
                    if (agentPhoto.ContentLength > 0)
                    {
                        Int32  length    = agentPhoto.ContentLength;
                        byte[] tempImage = new byte[length];
                        agentPhoto.InputStream.Read(tempImage, 0, length);
                        client.Logo        = tempImage;// file.InputStream;
                        client.ContentType = agentPhoto.ContentType;
                    }
                }
                if (ClientModels.CreateClient(client) > 0)
                {
                    ApplicationMessages msg = new ApplicationMessages("New Employee saved successfully.", MessageType.Success);
                    ViewData["Message"] = msg;
                    return(RedirectToAction("List"));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Exemple #22
0
    private void DoUpdateAction(GridEditableItem item)
    {
        ConversionUtils conversionUtils = new ConversionUtils();

        int       idCurrency = 0;
        Hashtable newValues  = new Hashtable();

        //Extract the values entered by the user
        item.ExtractValues(newValues);
        //If the new value is null, convert it to the empty string to avoid multiple null checks
        if (newValues["BudgetExchangeRate"] == null)
        {
            newValues["BudgetExchangeRate"] = String.Empty;
        }

        ArrayList errors = new ArrayList();
        decimal   rate   = 0;

        //Check if the update hour is of decimal type
        if (!String.IsNullOrEmpty(newValues["BudgetExchangeRate"].ToString()) && decimal.TryParse(newValues["BudgetExchangeRate"].ToString(), out rate) == false)
        {
            errors.Add(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_NOT_NUMERIC, "Budget Exchange Rate"));
        }
        if (String.IsNullOrEmpty(newValues["BudgetExchangeRate"].ToString()))
        {
            errors.Add(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_CANNOT_BE_EMPTY, "Budget Exchange Rate"));
        }
        if (rate < 0)
        {
            errors.Add(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_FIELD_MUST_BE_POSITIVE, "Budget Exchange Rate"));
        }
        string temp = item.GetDataKeyValue("IdCurrency").ToString();

        if (string.IsNullOrEmpty(temp) || !int.TryParse(temp, out idCurrency))
        {
            errors.Add(ApplicationMessages.MessageWithParameters("IdCurrency is missing", "Budget Exchange Rate"));
        }

        //If there are errors the update shouldn't be done
        if (errors.Count != 0)
        {
            throw new IndException(errors);
        }

        UpdateBudgetExchangeRate(idCurrency, rate);
    }
Exemple #23
0
        public ActionResult Notification(FormCollection form, SMSNotices newSMS)
        {
            if (!ModelState.IsValid)
            {
                ApplicationMessages msg = new ApplicationMessages("Message Sent failed.", MessageType.Faild);
                ViewData["Message"] = msg;
                return(View());
            }

            string cell = string.Empty;

            if (newSMS.MobileNumber.Length > 10)
            {
                cell = "91" + newSMS.MobileNumber.Substring(newSMS.MobileNumber.Length - 10, 10);
            }
            else
            {
                if (newSMS.MobileNumber.Length == 10)
                {
                    cell = "91" + newSMS.MobileNumber.Substring(0, 10);
                }
            }
            if (!string.IsNullOrEmpty(cell))
            {
                ViewData["SendString"] = "http://199.189.250.157/smsclient/api.php?username=scan&password=27963108&source=senderid&dmobile=" + cell + "&message=" + newSMS.SMSText;
                if (MasterModels.SendSMS(newSMS) > 0)
                {
                    ApplicationMessages msg1 = new ApplicationMessages("Message Sent successfully.", MessageType.Success);
                    ViewData["Message"] = msg1;
                }
                else
                {
                    ApplicationMessages msg = new ApplicationMessages("Message Sent failed.", MessageType.Faild);
                    ViewData["Message"] = msg;
                }
            }
            else
            {
                ApplicationMessages msg = new ApplicationMessages("Invalid Mobile Number.", MessageType.Faild);
                ViewData["Message"] = msg;
            }

            return(View());
        }
Exemple #24
0
 /// <summary>
 /// Checks if the given value is null (for its type)
 /// </summary>
 /// <param name="value">the value that is checked for null</param>
 /// <returns>true if the value is null (for its type), false otherwise</returns>
 public static bool AssertValueIsNull(object value)
 {
     if (value.GetType() == typeof(int))
     {
         return((int)value == ApplicationConstants.INT_NULL_VALUE || (int)value == ApplicationConstants.INT_NULL_VALUE_FOR_VALUE_FIELDS);
     }
     if (value.GetType() == typeof(short))
     {
         return((short)value == ApplicationConstants.SHORT_NULL_VALUE);
     }
     if (value.GetType() == typeof(decimal))
     {
         return((decimal)value == ApplicationConstants.DECIMAL_NULL_VALUE);
     }
     if (value.GetType() == typeof(string))
     {
         return(String.IsNullOrEmpty((string)value));
     }
     throw new ArgumentException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_NULL_VALUE_FOR_TYPE_IS_NOT_DEFINED, value.GetType().ToString()));
 }
Exemple #25
0
        public ActionResult Register(RegisterModel model)
        {
            if (Roles.GetRolesForUser().Contains("Admin"))
            {
                string[] rolesToHide = { "Admin", "SuperAdmin" };
                ViewData["UserRoles"] = Registration.GetRoleList(rolesToHide);
            }
            else
            {
                ViewData["UserRoles"] = Registration.GetRoleList(null);
                ViewData["Clients"]   = ClientModels.GetClientNameList();
            }

            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    if (Session["ClientId"] != null)
                    {
                        model.ClientId = (int)Session["ClientId"];
                    }
                    //  FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
                    Registration.AssignRoleToUser(model);
                    ApplicationMessages msg = new ApplicationMessages("New Employee saved successfully.", MessageType.Success);
                    ViewData["Message"] = msg;
                    return(View());
                    //return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            return(View(model));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (IdImport == ApplicationConstants.INT_NULL_VALUE)
            {
                throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_COULD_NOT_GET_PARAMETER, "IdImport"));
            }
            else
            {
                //The first time the page loads, remove the information from DsLogs (session) such that data from a previous log is not shown
                //instead of correct data
                if (!IsPostBack)
                {
                    DsLogs = null;
                }

                //Loads the data
                LoadEditableGrid();
                LoadHeader();

                CurrentUser usr = SessionManager.GetCurrentUser(this);

                //Get the moduleCode from the parent Ascx
                string moduleCode = ApplicationConstants.MODULE_DATA_LOGS;

                _UserCanDelete = usr.GetPermission(moduleCode, Operations.ManageLogs) == Permissions.All;
            }
        }
        catch (IndException ex)
        {
            ShowError(ex);
            return;
        }
        catch (Exception ex)
        {
            ShowError(new IndException(ex));
            return;
        }
    }
Exemple #27
0
        public ActionResult NewBranch()
        {
            ViewData["BranchTypes"] = Utilities.GetBranchTypeList();
            ViewData["States"]      = Utilities.GetStateList(Utilities.IndiaCountryCode);
            ViewData["Countries"]   = Utilities.GetCountryList();
            if (Session["ClientId"] != null)
            {
                vw_ClientList clientDetails = ClientModels.GetClientDetailsById((int)Session["ClientId"]);
                int           branchCount   = BranchModels.GetBranchesList((int)Session["ClientId"]).Count();

                ViewData["Zones"] = Utilities.GetZoneNameList((int)Session["ClientId"]);
                if (Session["ZoneId"] != null)
                {
                    ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], (int)Session["ZoneId"]);
                }
                else
                {
                    ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], null);
                }
                if (branchCount >= clientDetails.NoOfSchoolsPermitted)
                {
                    ApplicationMessages msg = new ApplicationMessages("Your have reached to branch count max limit. Please contact administrator..", MessageType.Information);
                    ViewData["Message"] = msg;
                    return(View());
                }
            }
            else
            {
                if (Roles.IsUserInRole("SuperAdmin"))
                {
                    return(RedirectToAction("List", "Client"));
                }
                else
                {
                    return(RedirectToAction("Logon", "Account"));
                }
            }

            return(View());
        }
Exemple #28
0
        public ActionResult EditBatch(FormCollection form, Batches batch, int id)
        {
            if (Session["ClientId"] != null)
            {
                if (!Roles.IsUserInRole("CenterManager"))
                {
                    ViewData["Branches"] = Utilities.GetBranchNameList((int)Session["ClientId"]);
                }
                else
                {
                    if (Session["BranchId"] != null)
                    {
                        ViewData["Branches"] = null;// Utilities.GetBlankBranchNameList();
                    }
                    else
                    {
                        return(RedirectToAction("LogOff", "Account"));
                    }
                }
            }
            else
            {
                if (Roles.IsUserInRole("SuperAdmin"))
                {
                    return(RedirectToAction("List", "Client"));
                }
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }
            if (CourseModels.UpdateBatch(batch) > 0)
            {
                ApplicationMessages msg = new ApplicationMessages("Batch Information updated successfully.", MessageType.Success);
                ViewData["Message"] = msg;
            }

            return(View());
        }
Exemple #29
0
        /// <summary>
        /// NeedDataSource event handler of the generic grid
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void GenericGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            try
            {
                this.MasterTableView.FilterExpression = this.IndFilterExpression;
                if (!_UseAutomaticEntityBinding && _VirtualDataSource == null)
                {
                    return;
                }
                //Clear the columns in the master table
                this.MasterTableView.Columns.Clear();

                //Add the edit column
                AddEditColumn();

                //Add the delete column (checkbox column)
                AddDeleteColumn();

                DataSet sourceDS = new DataSet();

                if (_UseAutomaticEntityBinding)
                {
                    //Instantiate the referenced object
                    IGenericEntity viewEntity = EntityFactory.GetEntityInstance(_EntityType, SessionManager.GetSessionValueNoRedirect((IndBasePage)this.Page, SessionStrings.CONNECTION_MANAGER));

                    ((GenericUserControl)this.Parent.Parent).SetViewEntityProperties(viewEntity);
                    //Get all entities in this catalogue
                    sourceDS = viewEntity.GetAll(true);

                    //Creates a new GenericEntity object with the correct instance that will be used to add the logical column
                    object connectionManager = SessionManager.GetSessionValueNoRedirect((IndBasePage)this.Page, SessionStrings.CONNECTION_MANAGER);

                    //Add the logical column
                    EntityFactory.GetEntityInstance(this.EntityType, connectionManager).CreateLogicalKeyColumn(sourceDS.Tables[0]);
                }
                else
                {
                    if (!(_VirtualDataSource is DataSet) && !(_VirtualDataSource is DataTable))
                    {
                        throw new IndException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_VIRTUAL_DATASOURCE_OF_TYPE_NOT_SUPPORTED, _VirtualDataSource.GetType().ToString()));
                    }
                    if (_VirtualDataSource is DataSet)
                    {
                        sourceDS = (DataSet)_VirtualDataSource;
                    }
                    if (_VirtualDataSource is DataTable)
                    {
                        sourceDS.Tables.Add((DataTable)_VirtualDataSource);
                    }
                }

                //Add the data columns (with data from the db) to the grid
                AddDataColumns(sourceDS);

                if (_UseAutomaticEntityBinding)
                {
                    CurrentUser currentUser = SessionManager.GetSessionValueRedirect((IndBasePage)this.Page, SessionStrings.CURRENT_USER) as CurrentUser;
                    if (currentUser.HasEditPermission(ApplicationConstants.MODULE_HOURLY_RATE) && _EntityType == typeof(HourlyRate))
                    {
                        AddColumnHeaderControl("Value", "&nbsp<input type=\"image\" id=\"btnMassAttr\" class=\"IndImageButton\" title=\"Mass Attribution\" src=\"Images/mass_attribution_up.gif\" onclick=\"if (ShowPopUpWithoutPostBack('UserControls/Catalogs/HourlyRate/HRMassAttribution.aspx',520,560, '" + ResolveUrl("~/Default.aspx?SessionExpired=1") + "')){ __doPostBack('" + this.Page.ClientID + "',null);}return false;\"");
                    }

                    //Hide the columns that must not be shown (like Id)
                    HideColumns();
                }


                //Bind the grid to the dataset
                this.DataSource = sourceDS;

                SetDateColumnFormatString();
            }
            catch (IndException ex)
            {
                ControlHierarchyManager.ReportError(ex);
                return;
            }
            catch (Exception ex)
            {
                ControlHierarchyManager.ReportError(new IndException(ex));
                return;
            }
        }
Exemple #30
0
 public void SetMessageType(ApplicationMessages messageType)
 {
     Data[1] = (byte)messageType;
 }