public List <MVCModels.HiDoctor_Master.WeekendGroup> GetWeekendGroupHeader()
        {
            string companyCode = _objCurInfo.GetCompanyCode();
            List <MVCModels.HiDoctor_Master.WeekendGroup> lstWeekendGroup = new List <MVCModels.HiDoctor_Master.WeekendGroup>();

            try
            {
                _objData.OpenConnection(companyCode);
                {
                    using (sqldataReader = _objData.ExecuteReader("" + EXEC + " " + SP_HDGETWEEKENDGROUPNAME + " '" + companyCode + "'"))
                    {
                        while (sqldataReader.Read())
                        {
                            MVCModels.HiDoctor_Master.WeekendGroup objWeekendGroup = new MVCModels.HiDoctor_Master.WeekendGroup();
                            objWeekendGroup.Weekend_Off_Code = sqldataReader["Weekend_Off_Code"].ToString();
                            objWeekendGroup.Weekend_Off_Name = sqldataReader["Weekend_Off_Name"].ToString();
                            lstWeekendGroup.Add(objWeekendGroup);
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                _objData.CloseConnection();
            }
            return(lstWeekendGroup);
        }
        public bool InsertMappedRegions(DataTable dtRegCodes, string UserName)
        {
            bool result = false;

            try
            {
                SqlCommand command = new SqlCommand("SP_HD_InsertMappedRegion");
                command.CommandType = CommandType.StoredProcedure;
                //using (IDbConnection connection = IDbOpenConnection())
                //{
                //    var p = new DynamicParameters();
                //    p.Add("@UserName", UserName);
                //    result=connection.Execute(SP_HD_InsertMappedRegion, p, commandType: CommandType.StoredProcedure);
                //    connection.Close();
                //}

                if (dtRegCodes.Rows.Count == 0)
                {
                    _objSPData.AddParamToSqlCommandWithTypeName(command, "@TVP_DCRStatus_RegionCodes", ParameterDirection.Input, SqlDbType.Structured, null, "TVP_DCRStatus_RegionCodes");
                }
                else
                {
                    _objSPData.AddParamToSqlCommandWithTypeName(command, "@TVP_DCRStatus_RegionCodes", ParameterDirection.Input, SqlDbType.Structured, dtRegCodes, "TVP_DCRStatus_RegionCodes");
                }
                _objData.OpenConnection();
                _objData.ExecuteNonQuery(command);
                result = true;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
Esempio n. 3
0
        //Fill DDL Division , Region-Type , Region-Classification , User-Type , Expense-Header-Group
        #region Get ExpenseMapping Master Data
        public DataSet GetExpenseMappingMasterData()
        {
            DataSet ds = new DataSet();


            objData.OpenConnection(_ObjCurInfo.GetCompanyCode());
            {
                string StrSQL = "EXEC SP_hdGetExpenseMappingMasterData " + _ObjCurInfo.GetCompanyCode();
                ds = objData.ExecuteDataSet(StrSQL);
                objData.CloseConnection();
            }
            return(ds);
        }
Esempio n. 4
0
        public bool CheckSfcMasterExist()
        {
            try
            {
                bool flag = false;
                DataControl.CurrentInfo objCurr = new DataControl.CurrentInfo();
                DataControl.Data        objData = new DataControl.Data();
                string companyCode = objCurr.GetCompanyCode();
                string regionCode  = objCurr.GetRegionCode();
                int    result      = 0;

                objData.OpenConnection(companyCode);
                {
                    result = Convert.ToInt32(objData.ExecuteScalar("exec SP_hdCheckSfcMasterExist '" + companyCode + "','" + regionCode + "'"));
                }
                objData.CloseConnection();

                if (result > 0)
                {
                    flag = true;
                }
                return(flag);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        public bool InsertUserSession()
        {
            DataControl.Data objData = new DataControl.Data();
            try
            {
                string macId       = GetMACInformation();
                string ipAddress   = Request.ServerVariables["REMOTE_ADDR"].ToString();
                string browserName = Request.Browser.Browser + " " + Request.Browser.MajorVersion.ToString() + "." + Request.Browser.MinorVersion.ToString();
                string companyCode = _objCurInfo.GetCompanyCode();
                string userCode    = _objCurInfo.GetUserCode();
                string userName    = _objCurInfo.GetUserName();
                string sessionId   = _objCurInfo.GetSessionId();
                string latitude    = _objCurInfo.GetLattitude();
                string longitude   = _objCurInfo.GetLongitude();
                string location    = _objCurInfo.GetLocation();
                string loginTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff");

                bool isTrue = false;


                objData.OpenConnection(_objCurInfo.GetCompanyCode());
                {
                    objData.ExecuteNonQuery("exec sp_sdInsertUserSession '" + _objCurInfo.GetCompanyCode() + "','" + _objCurInfo.GetUserCode() + "','" + _objCurInfo.GetUserName() + "','" + _objCurInfo.GetSessionId() + "','" + loginTime + "','" + ipAddress + "','" + macId + "','" + browserName + "','" + latitude + "','" + longitude + "','" + location + "'");
                }

                return(isTrue);
            }
            finally
            {
                objData.CloseConnection();
            }
        }
Esempio n. 6
0
        public bool InsertMasterData(DataTable dtUserCodes)
        {
            bool result = false;

            try
            {
                SqlCommand command = new SqlCommand("SP_HD_InsertMasterData");
                command.CommandType = CommandType.StoredProcedure;
                if (dtUserCodes.Rows.Count == 0)
                {
                    _objSPData.AddParamToSqlCommandWithTypeName(command, "@TVP_MasterData_Details", ParameterDirection.Input, SqlDbType.Structured, null, "TVP_MasterData_Details");
                }
                else
                {
                    _objSPData.AddParamToSqlCommandWithTypeName(command, "@TVP_MasterData_Details", ParameterDirection.Input, SqlDbType.Structured, dtUserCodes, "TVP_MasterData_Details");
                }
                _objData.OpenConnection();
                _objData.ExecuteNonQuery(command);
                result = true;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
Esempio n. 7
0
        public JsonResult GetTPHeader(string userCode)
        {
            if (userCode.ToUpper() == "MINE")
            {
                userCode = objCurr.GetUserCode();
            }

            DataSet dsTpHeader = new DataSet();

            objData.OpenConnection(objCurr.GetCompanyCode());
            {
                dsTpHeader = objData.ExecuteDataSet("exec SP_mhdGetTPReport '" + objCurr.GetCompanyCode() + "','" + userCode + "'");
            }
            objData.CloseConnection();
            DataControl.JSONConverter json = new DataControl.JSONConverter();
            return(Json(json.Serialize(dsTpHeader)));
        }
Esempio n. 8
0
        public int InsertSplashScreenData(string companyCode, SplashScreenModel objSplashScreenModel)
        {
            int result = 0;

            try
            {
                SqlCommand command = new SqlCommand(SP_SC_INSERT_SPLASH_SCREEN_DATA);
                command.CommandType = CommandType.StoredProcedure;

                _objSPData.AddParamToSqlCommand(command, "@Company_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, companyCode);
                _objSPData.AddParamToSqlCommand(command, "@Splash_Type", ParameterDirection.Input, SqlDbType.VarChar, 150, objSplashScreenModel.Splash_Type);
                _objSPData.AddParamToSqlCommand(command, "@Title", ParameterDirection.Input, SqlDbType.VarChar, 150, objSplashScreenModel.Title);
                _objSPData.AddParamToSqlCommand(command, "@Description", ParameterDirection.Input, SqlDbType.VarChar, 1000, objSplashScreenModel.Description);
                _objSPData.AddParamToSqlCommand(command, "@File_Path", ParameterDirection.Input, SqlDbType.VarChar, 250, objSplashScreenModel.File_Path);
                _objSPData.AddParamToSqlCommand(command, "@Date_From", ParameterDirection.Input, SqlDbType.Date, 30, objSplashScreenModel.Date_From);
                _objSPData.AddParamToSqlCommand(command, "@Date_To", ParameterDirection.Input, SqlDbType.Date, 30, objSplashScreenModel.Date_To);
                _objSPData.AddParamToSqlCommand(command, "@Has_Attachment", ParameterDirection.Input, SqlDbType.Int, 4, objSplashScreenModel.Has_Attachment);
                _objSPData.AddParamToSqlCommand(command, "@Mobile_Attachment_Url", ParameterDirection.Input, SqlDbType.VarChar, 250, objSplashScreenModel.Mobile_Attachment_Url);
                _objSPData.AddParamToSqlCommand(command, "@Assigned_To_All_Users", ParameterDirection.Input, SqlDbType.Int, 4, objSplashScreenModel.Assigned_To_All_Users);
                _objSPData.AddParamToSqlCommand(command, "@Is_Completed", ParameterDirection.Input, SqlDbType.Int, 4, objSplashScreenModel.Is_Completed);
                _objSPData.AddParamToSqlCommand(command, "@Last_Modified_DateTime", ParameterDirection.Input, SqlDbType.DateTime, 20, objSplashScreenModel.Last_Modified_DateTime);
                _objSPData.AddParamToSqlCommand(command, "@Description_HTML", ParameterDirection.Input, SqlDbType.VarChar, -1, objSplashScreenModel.Description_HTML);
                SqlParameter returnValue = new SqlParameter("@Result", SqlDbType.Int);
                returnValue.Direction = ParameterDirection.Output;
                returnValue.Size      = 500;
                returnValue.Value     = "";
                command.Parameters.Add(returnValue);
                _objData.OpenConnection(companyCode);
                _objData.ExecuteNonQuery(command);
                result = Convert.ToInt32(returnValue.Value);
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _objData.CloseConnection();
            }
        }
Esempio n. 9
0
        public DataSet GetAllExpense()
        {
            DataSet dssub = new DataSet();

            objData.OpenConnection(objCurrentInfo.GetCompanyCode());
            {
                string StrSQL = "EXEC SP_hd_ExpenseType_Select " + objCurrentInfo.GetCompanyCode();
                dssub = objData.ExecuteDataSet(StrSQL);
                objData.CloseConnection();
            }

            return(dssub);
        }
Esempio n. 10
0
        public string ExpenseInsert(string storedProcedure, string expensetypeCode, string companyCode, string expensetypeName, string expensetypeStatus, string expenseMode,
                                    string Period, string Mode, string displayOrder)
        {
            try
            {
                DataControl.CurrentInfo objCurentInfo = new DataControl.CurrentInfo();
                //string conStr = objData.GetConnectionString(objCurentInfo.GetCompanyCode());
                //con.ConnectionString = conStr;

                DataControl.Data db = new DataControl.Data();


                // Command - specify as StoredProcedure
                SqlCommand command = new SqlCommand(storedProcedure, con);
                command.CommandType = CommandType.StoredProcedure;

                AddParamToSqlCommand(command, "@Company_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, companyCode);
                AddParamToSqlCommand(command, "@Expense_Type_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, expensetypeCode);
                AddParamToSqlCommand(command, "@Expense_Type_Name", ParameterDirection.Input, SqlDbType.VarChar, 50, expensetypeName);
                AddParamToSqlCommand(command, "@Expense_Type_Status", ParameterDirection.Input, SqlDbType.VarChar, 30, expensetypeStatus);
                AddParamToSqlCommand(command, "@Expense_Mode", ParameterDirection.Input, SqlDbType.VarChar, 30, expenseMode);
                AddParamToSqlCommand(command, "@Expense_Period", ParameterDirection.Input, SqlDbType.VarChar, 30, Period);
                AddParamToSqlCommand(command, "@Mode", ParameterDirection.Input, SqlDbType.VarChar, 30, Mode);
                AddParamToSqlCommand(command, "@DisplayOrder", ParameterDirection.Input, SqlDbType.VarChar, 30, displayOrder);


                // Return value as parameter
                SqlParameter returnValue = new SqlParameter("@Result", SqlDbType.VarChar);
                returnValue.Direction = ParameterDirection.Output;
                returnValue.Size      = 500;
                command.Parameters.Add(returnValue);

                if (db.OpenConnection(objCurentInfo.GetCompanyCode()))
                {
                    // Execute the stored procedure
                    db.ExecuteNonQuery(command);
                    db.CloseConnection();
                }

                //For Handle the Error

                return(returnValue.Value.ToString());
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex, "ExpenseInsert()");
                return("ERROR");
            }
        }
Esempio n. 11
0
        public string Inward(string storedProcedure, string companyCode, string UserCode, string ProductCode, string InwardDate, string Inwardstock, string UserInwardCode, string UserInwarddetails, string CurrentStock)
        {
            try
            {
                DataControl.CurrentInfo objCurentInfo = new DataControl.CurrentInfo();
                //string conStr = objData.GetConnectionString(objCurentInfo.GetCompanyCode());
                //con.ConnectionString = conStr;

                DataControl.Data db = new DataControl.Data();


                // Command - specify as StoredProcedure
                SqlCommand command = new SqlCommand(storedProcedure, con);
                command.CommandType = CommandType.StoredProcedure;

                AddParamToSqlCommand(command, "@Company_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, companyCode);
                AddParamToSqlCommand(command, "@User_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, UserCode);
                AddParamToSqlCommand(command, "@Product_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, ProductCode);
                AddParamToSqlCommand(command, "@Inward_Date", ParameterDirection.Input, SqlDbType.VarChar, 30, InwardDate);
                AddParamToSqlCommand(command, "@Inward_stock", ParameterDirection.Input, SqlDbType.VarChar, 30, Inwardstock);
                AddParamToSqlCommand(command, "@User_Inward_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, UserInwardCode);
                AddParamToSqlCommand(command, "@User_Inward_Detail", ParameterDirection.Input, SqlDbType.VarChar, 30, UserInwarddetails);
                AddParamToSqlCommand(command, "@Current_Stock", ParameterDirection.Input, SqlDbType.VarChar, 30, CurrentStock);
                // Return value as parameter
                SqlParameter returnValue = new SqlParameter("@Result", SqlDbType.VarChar);
                returnValue.Direction = ParameterDirection.Output;
                returnValue.Size      = 500;
                command.Parameters.Add(returnValue);

                if (db.OpenConnection(objCurentInfo.GetCompanyCode()))
                {
                    // Execute the stored procedure
                    db.ExecuteNonQuery(command);
                    db.CloseConnection();
                }

                //For Handle the Error

                return(returnValue.Value.ToString());
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex, "Inward()");
                return("ERROR");
            }
        }
Esempio n. 12
0
        public string productInsert(string storedProcedure, string companyCode, string salesproductCode, string mappingproductCode, string effectiveFrom, string createdDate, string createdBy, string recordStatus)
        {
            try
            {
                DataControl.CurrentInfo objCurentInfo = new DataControl.CurrentInfo();
                //string conStr = objData.GetConnectionString(objCurentInfo.GetCompanyCode());
                //con.ConnectionString = conStr;

                DataControl.Data db = new DataControl.Data();


                // Command - specify as StoredProcedure
                SqlCommand command = new SqlCommand(storedProcedure, con);
                command.CommandType = CommandType.StoredProcedure;

                AddParamToSqlCommand(command, "@Company_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, companyCode);
                AddParamToSqlCommand(command, "@Sales_Product_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, salesproductCode);
                AddParamToSqlCommand(command, "@Mapping_Product_Code", ParameterDirection.Input, SqlDbType.VarChar, 30, mappingproductCode);
                AddParamToSqlCommand(command, "@Effective_From", ParameterDirection.Input, SqlDbType.VarChar, 30, effectiveFrom);
                AddParamToSqlCommand(command, "@Created_Date", ParameterDirection.Input, SqlDbType.VarChar, 30, createdDate);
                AddParamToSqlCommand(command, "@Created_By", ParameterDirection.Input, SqlDbType.VarChar, 30, createdBy);
                AddParamToSqlCommand(command, "@Record_Status", ParameterDirection.Input, SqlDbType.VarChar, 1, recordStatus);
                // Return value as parameter
                SqlParameter returnValue = new SqlParameter("@Result", SqlDbType.VarChar);
                returnValue.Direction = ParameterDirection.Output;
                returnValue.Size      = 500;
                command.Parameters.Add(returnValue);

                if (db.OpenConnection(objCurentInfo.GetCompanyCode()))
                {
                    // Execute the stored procedure
                    db.ExecuteNonQuery(command);
                    db.CloseConnection();
                }

                //For Handle the Error

                return(returnValue.Value.ToString());
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex, "productInsert()");
                return("ERROR");
            }
        }
Esempio n. 13
0
        public JsonResult GetWeekendGroup(FormCollection collection)
        {
            try
            {
                string RegionCode = string.Empty;
                RegionCode = collection["RegionCode"];
                string mode = string.Empty;
                mode = collection["Mode"];

                DataSet dsReport = new DataSet();
                DataControl.JSONConverter json = new DataControl.JSONConverter();
                _objData.OpenConnection(_objcurrentInfo.GetCompanyCode());
                dsReport = _objSPData.GetWeekendgroupdetail(_objcurrentInfo.GetCompanyCode(), RegionCode, mode);
                //dsReport = _objData.ExecuteDataSet("EXEC SP_hdGETRegionWeekengGroupMapping " + "'" + _objcurrentInfo.GetCompanyCode() + "','" + RegionCode + "'");
                return(Json(json.Serialize(dsReport), JsonRequestBehavior.AllowGet));
            }
            finally
            {
                _objData.CloseConnection();
            }
        }
Esempio n. 14
0
        public List <Models.MasterModel> UserDetails(string userCode, string companyCode)
        {
            try
            {
                List <Models.MasterModel> lstUserDetail = new List <Models.MasterModel>();

                _objData.OpenConnection(companyCode);
                using (IDataReader reader = _objData.ExecuteReader("exec SP_hdGetTpVsActualDeviationSummary '" + companyCode + "', '" + userCode + "','','','USER'"))
                {
                    lstUserDetail = DataReaderMapToList <Models.MasterModel>(reader);
                }
                _objData.CloseConnection();

                return(lstUserDetail);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _objData.CloseConnection();
            }
        }
Esempio n. 15
0
        public double CalculateSFCFare(Models.FareCalculationDTO fareCalcPassed)
        {
            try
            {
                double totalFare = 0.0;
                string hopNeed   = fareCalcPassed.IntermediatePlace;
                string entity    = fareCalcPassed.Entity;
                string dcrCode   = fareCalcPassed.DcrCode;
                string dcrDate   = fareCalcPassed.DcrDate;
                string dcrFlag   = fareCalcPassed.DcrFalg;

                Controllers.MasterController objMaster = new Controllers.MasterController();
                DataControl.CurrentInfo      objCurr   = new DataControl.CurrentInfo();
                DataControl.Data             objData   = new DataControl.Data();

                string companyCode = objCurr.GetCompanyCode();
                string userCode    = objCurr.GetUserCode();
                string regionCode  = objCurr.GetRegionCode();

                if (entity == "HQ")
                {
                    DataSet dsHop = new DataSet();

                    objData.OpenConnection(companyCode);
                    {
                        dsHop = objData.ExecuteDataSet("exec SP_hdGetHopPlaces '" + companyCode + "','" + dcrCode + "','" + userCode + "','" + dcrDate + "','" + dcrFlag + "'");
                    }
                    objData.CloseConnection();

                    if (dsHop.Tables[0].Rows.Count > 0)
                    {
                        try
                        {
                            objData.OpenConnection(companyCode);
                            {
                                totalFare = Convert.ToDouble(objData.ExecuteScalar("exec SP_hdGetSFCAmount '" + companyCode + "','" + dsHop.Tables[0].Rows[0]["SFC_Region_Code"].ToString().Trim() + "','" + dsHop.Tables[0].Rows[0]["From_Place"].ToString().Trim() + "','" + dsHop.Tables[0].Rows[0]["To_Place"].ToString().Trim() + "','" + dsHop.Tables[0].Rows[0]["SFC_Category_Name"].ToString().Trim() + "','" + dsHop.Tables[0].Rows[0]["Travel_Mode"].ToString().Trim() + "','" + dcrDate + "','" + userCode + "','" + regionCode + "','" + entity + "'"));
                            }
                            objData.CloseConnection();
                        }
                        catch
                        {
                            totalFare = 0.0;
                        }
                    }
                }
                else
                {
                    DataSet dsTravelPlace  = new DataSet();
                    double  fareAmount     = 0.0;
                    double  travelDistance = 0.0;

                    dsTravelPlace = objMaster.GetTrvelPlace(companyCode, dcrCode, dcrFlag, userCode, dcrDate);

                    if (dsTravelPlace.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in dsTravelPlace.Tables[0].Rows)
                        {
                            travelDistance = Convert.ToDouble(dr["Distance"].ToString().Trim());
                            try
                            {
                                objData.OpenConnection(companyCode);
                                {
                                    fareAmount = Convert.ToDouble(objData.ExecuteScalar("exec SP_hdGetSFCAmount '" + companyCode + "','" + dr["SFC_Region_Code"].ToString().Trim() + "','" + dr["From_Place"].ToString().Trim() + "','" + dr["To_Place"].ToString().Trim() + "','" + dr["SFC_Category_Name"].ToString().Trim() + "','" + dr["Travel_Mode"].ToString().Trim() + "','" + dcrDate + "','" + userCode + "','" + regionCode + "','" + entity + "'"));
                                }
                                objData.CloseConnection();
                            }
                            catch
                            {
                                fareAmount = 0.0;
                            }
                            totalFare += fareAmount;
                        }
                    }
                }
                return(totalFare);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 16
0
        public string GetLogin(FormCollection collection)
        {
            try
            {
                //System.Web.HttpContext.Current.Session["Comp_Code"] = null;
                bool isTrue; //= _objCurInfo.SetCompanyCode();

                //if (!isTrue)
                //{
                //    return "FAILURE:Unable to open database";
                //}

                string companyCode     = _objCurInfo.GetCompanyCode();
                string userName        = collection["userName"].ToString();
                string password        = collection["password"].ToString();
                string userCode        = string.Empty;
                string privValue       = string.Empty;
                string commonPassword  = _objCurInfo.GetCommonPassword();
                string errMsg          = string.Empty;
                string isCaseSensitive = "0";
                isTrue = false;
                DataSet dsPrivilege = new DataSet();
                DataSet dsUserInfo  = new DataSet();

                _latitude      = collection["latitude"].ToString();
                _longitude     = collection["longitude"].ToString();
                _sourceOfEntry = collection["sourceOfEntry"].ToString();

                if (_data.OpenConnection(companyCode))
                {
                    dsPrivilege = _objData.GetPrivilegeData(companyCode, userName);
                    _data.CloseConnection();
                }

                if (dsPrivilege != null && dsPrivilege.Tables.Count > 0)
                {
                    _objCurInfo.SetPrivilegeValues(dsPrivilege);

                    privValue = _objCurInfo.GetPrivilegeValue("PASSWORD_POLICY", "NO");

                    if (privValue == "YES") // Password policy privilege is enabled
                    {
                        privValue = _objCurInfo.GetPrivilegeValue("PASSWORD_STRENGTH", "WEAK");
                        if (privValue == "GOOD" || privValue == "STRONG" || privValue == "VERY_STRONG")
                        {
                            isCaseSensitive = "1"; // Password should be case sensitive
                        }
                    }

                    dsUserInfo = _objData.CheckUserAuthentication(companyCode, userName, password, commonPassword, isCaseSensitive);
                    privValue  = _objCurInfo.GetPrivilegeValue("PASSWORD_POLICY", "NO");

                    if (privValue == "YES")                                                                           // Password policy privilege is enabled
                    {
                        if (dsUserInfo != null && dsUserInfo.Tables.Count > 0 && dsUserInfo.Tables[0].Rows.Count > 0) // Valid username password
                        {
                            userCode = dsUserInfo.Tables[0].Rows[0]["User_Code"].ToString().Trim();

                            if (dsUserInfo.Tables[0].Rows[0]["Status"].ToString().Trim().ToUpper() == USER_STATUS_VALID)
                            {
                                isTrue = IsAccountLocked(dsUserInfo);
                                if (isTrue)                                                         // Account is locked
                                {
                                    errMsg = ReleaseUserAccount(companyCode, userCode, dsUserInfo); // Account is released after the grace period

                                    if (errMsg == string.Empty)
                                    {
                                        errMsg = RedirectToPage(companyCode, "YES", userCode, dsUserInfo);
                                    }
                                    else
                                    {
                                        return(errMsg); // Still account is locked
                                    }
                                }
                                else
                                {
                                    errMsg = RedirectToPage(companyCode, "YES", userCode, dsUserInfo); // Account is not locked
                                }
                            }
                            else
                            {
                                errMsg = LockUserAccount(companyCode, userCode, dsUserInfo); // Lock user account
                                return(errMsg);
                            }
                        }
                        else
                        {
                            errMsg = "Invalid username or password";
                            return(errMsg);
                        }
                    }
                    else
                    {
                        if (dsUserInfo != null && dsUserInfo.Tables.Count > 0 && dsUserInfo.Tables[0].Rows.Count > 0) // Valid username password
                        {
                            if (dsUserInfo.Tables[0].Rows[0]["Status"].ToString().Trim().ToUpper() == "VALID")
                            {
                                userCode = dsUserInfo.Tables[0].Rows[0]["User_Code"].ToString();
                                errMsg   = RedirectToPage(companyCode, "NO", userCode, dsUserInfo);
                            }
                            else
                            {
                                errMsg = "Invalid username or password";
                                return(errMsg);
                            }
                        }
                        else
                        {
                            errMsg = "Invalid username or password";
                        }
                    }
                }
                else
                {
                    errMsg = "Invalid username or password";
                }

                return(errMsg);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Esempio n. 17
0
        public string GetForgotpassword(FormCollection collection)
        {
            try
            {
                string userName = string.Empty;
                userName = collection["UserName"];
                string  result   = "";
                DataSet dsReport = new DataSet();
                DataControl.JSONConverter json = new DataControl.JSONConverter();

                try
                {
                    _objData.OpenConnection(_objcurrentInfo.GetCompanyCode());
                    dsReport = _objData.ExecuteDataSet("EXEC SP_HdGetCheckUsername " + "'" + _objcurrentInfo.GetCompanyCode() + "','" + userName + "'");
                }
                finally
                {
                    _objData.CloseConnection();
                }


                if (dsReport.Tables[0].Rows.Count != 0)
                {
                    string strEmailid  = dsReport.Tables[0].Rows[0]["Email_Id"].ToString();
                    string UserName    = dsReport.Tables[0].Rows[0]["User_Name"].ToString();
                    string strUserpass = dsReport.Tables[0].Rows[0]["User_Pass"].ToString();

                    if (!string.IsNullOrEmpty(strEmailid))
                    {
                        //string strSubject = "Dear Sir/Madam, \n\n Please keep a note of the following information which is critical for ensuring uninterrupted access to HiDOCTOR \n\n  Your User Id:  " + UserName + " \n  Your Password: "******" \n\n In case of any clarifications, please reach out to our support desk ([email protected] or 095600005628).\n\n Assuring you of our best services at all times.\n\n Warm Regards \n Customer Service ";
                        string  companyName  = "";
                        string  employeeName = "";
                        string  phoneNo      = "Not yet registered in HiDOCTOR";
                        string  mobileNo     = "Not yet registered in HiDOCTOR";
                        DataSet dsEmpInfo    = new DataSet();

                        try
                        {
                            _objData.OpenConnection(_objcurrentInfo.GetCompanyCode());
                            dsEmpInfo = _objData.ExecuteDataSet("EXEC SP_HdGetEmployeeDetail " + "'" + _objcurrentInfo.GetCompanyCode() + "','" + userName + "'");
                        }
                        finally
                        {
                            _objData.CloseConnection();
                        }

                        if (dsEmpInfo.Tables[0].Rows.Count > 0)
                        {
                            companyName  = dsEmpInfo.Tables[0].Rows[0]["Company_Name"].ToString().Trim();
                            employeeName = dsEmpInfo.Tables[0].Rows[0]["Employee_Name"].ToString().Trim();

                            if (dsEmpInfo.Tables[0].Rows[0]["Phone"].ToString().Trim().Length > 0)
                            {
                                phoneNo = dsEmpInfo.Tables[0].Rows[0]["Phone"].ToString().Trim();
                            }

                            if (dsEmpInfo.Tables[0].Rows[0]["Mobile"].ToString().Trim().Length > 0)
                            {
                                mobileNo = dsEmpInfo.Tables[0].Rows[0]["Mobile"].ToString().Trim();
                            }
                        }

                        string server   = ConfigurationManager.AppSettings["SMTPSERVER"];
                        string frommail = ConfigurationManager.AppSettings["FROMMAIL"];

                        string strSubject    = Resources.Password_Policy_Messages.PasswordLockReleaseMail.ToString();
                        string strSubjectNew = strSubject.Replace("@Name", UserName).Replace("@Pass", strUserpass);

                        strSubjectNew = strSubjectNew.Replace("@CompanyName", companyName);
                        strSubjectNew = strSubjectNew.Replace("@EmployeeName", employeeName);
                        strSubjectNew = strSubjectNew.Replace("@PhoneNo", phoneNo);
                        strSubjectNew = strSubjectNew.Replace("@MobileNo", mobileNo);

                        bool Issmtpmail = false;
                        Issmtpmail = _objSPData.SendMail(strEmailid, "Check your HiDOCTOR Password", strSubjectNew);
                        return("SUCCESS");
                    }
                    else
                    {
                        return("MAIL");
                    }
                }
                else
                {
                    return("FAILED");
                }
            }
            catch
            {
                return("FAILED");
            }
        }