Пример #1
0
        /*
         *
         * change made by vijay... by adding an overloaded function
         * of GetData which accepts UserId as the argument to get the accomodation types assigend to this
         * particular user
         *
         */
        private AccomTypeDTO[] GetData(int AccomodationTypeId, int UserId)
        {
            AccomTypeDTO[] objAccomodationTypeData;
            objAccomodationTypeData = null;
            DataSet ds;
            string  query = "select distinct a.accomtypeid, a.accomtype from tbluseraccomrights r  ";

            query += " inner join tblaccomtypemaster a on  r.accomtypeid = a.accomtypeid  ";
            query += " and userid = " + Convert.ToString(UserId);
            if (AccomodationTypeId != 0)
            {
                query += " and AccomTypeId=" + AccomodationTypeId;
                query += " order by AccomType";
            }
            ds = GetDataFromDB(query);
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                objAccomodationTypeData = new AccomTypeDTO[ds.Tables[0].Rows.Count];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    objAccomodationTypeData[i] = new AccomTypeDTO();
                    objAccomodationTypeData[i].AccomodationTypeId = Convert.ToInt32(ds.Tables[0].Rows[i][0]);
                    objAccomodationTypeData[i].AccomodationType   = Convert.ToString(ds.Tables[0].Rows[i][1]);
                }
            }
            return(objAccomodationTypeData);
        }
Пример #2
0
        public bool Delete(AccomTypeDTO oAccomTypeData)
        {
            string          sProcName;
            DatabaseManager oDB;

            try
            {
                oDB = new DatabaseManager();

                sProcName = "up_Del_AccomodationTypeMaster";
                oDB.DbCmd = oDB.GetStoredProcCommand(sProcName);
                oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iAccomodationTypeId", DbType.Int32, oAccomTypeData.AccomodationTypeId);
                oDB.ExecuteNonQuery(oDB.DbCmd);
            }
            catch (Exception exp)
            {
                oDB = null;
                GF.LogError("clsAccomodationMaster.Delete", exp.Message);
                return(false);
            }
            finally
            {
                oDB = null;
            }
            return(true);
        }
Пример #3
0
    private void Save()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Add))
        {
            return;
        }

        bool bActionCompleted = false;

        AccomodationTypeMaster oAccomTypeMaster = new AccomodationTypeMaster();
        AccomTypeDTO           oAccomTypeData   = MapControlsToObject();

        bActionCompleted = oAccomTypeMaster.Insert(oAccomTypeData);

        if (bActionCompleted == true)
        {
            txtAccomType.Text = "";
            base.DisplayAlert("The record has been inserted successfully");
        }
        else if (bActionCompleted == false)
        {
            base.DisplayAlert("The record has been not been inserted successfully");
            lblStatus.Text = "Error in saving.";
        }

        oAccomTypeData   = null;
        oAccomTypeMaster = null;
    }
Пример #4
0
    private void Delete()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Delete))
        {
            return;
        }

        int Id = 0;

        int.TryParse(hfId.Value, out Id);
        if (Id == 0)
        {
            lblStatus.Text = "Please click on edit again.";
            return;
        }
        if (txtAccomType.Text.Trim() == "")
        {
            lblStatus.Text = "Please enter the Accomodation Type.";
            return;
        }

        AccomTypeDTO           oAccomTypeData   = MapControlsToObject();
        AccomodationTypeMaster oAccomTypeMaster = new AccomodationTypeMaster();

        /*
         *
         * CHECK IF THE ACCOMODATION TYPE WHICH IS TO BE DELETED HAS ANY ASSOCIATED RECORDS...IF YES, MOVE OUT OF THE FUNCTION ELSE PROCEED
         * IF THE OUTPUT OF sMessage IS "", THEN RECORD CAN BE DELETED, ELSE NOT
         *
         */
        string sMessage = "";

        GF.HasRecords(Convert.ToString(Id), "accomodationtype", out sMessage);
        if (sMessage != "")
        {
            base.DisplayAlert(sMessage);
            btnDelete.Enabled = true;
        }
        else
        {
            bool bActionCompleted = oAccomTypeMaster.Delete(oAccomTypeData);
            if (bActionCompleted == true)
            {
                base.DisplayAlert("The record has been deleted successfully");
                txtAccomType.Text = "";
                //lblStatus.Text = "Deleted";
            }
            else
            {
                base.DisplayAlert("Error Occured while deletion: Please refer to the error log.");
            }
        }

        oAccomTypeData   = null;
        oAccomTypeMaster = null;
    }
Пример #5
0
    private AccomTypeDTO  MapControlsToObject()
    {
        AccomTypeDTO accomTypeDto = new AccomTypeDTO();
        int          Id;

        int.TryParse(hfId.Value, out Id);
        accomTypeDto.AccomodationTypeId = Id;
        accomTypeDto.AccomodationType   = txtAccomType.Text.ToString();
        return(accomTypeDto);
    }
Пример #6
0
    private void Update()
    {
        bool bActionCompleted = false;

        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Update))
        {
            return;
        }

        int Id = 0;

        int.TryParse(hfId.Value, out Id);
        if (Id == 0)
        {
            lblStatus.Text = "Please click on edit again.";
            return;
        }
        if (txtAccomType.Text.Trim() == "")
        {
            lblStatus.Text = "Please enter the Accomodation Type.";
            return;
        }


        AccomodationTypeMaster oAccomTypeMaster = new AccomodationTypeMaster();
        AccomTypeDTO           oAccomTypeData   = MapControlsToObject();

        bActionCompleted = oAccomTypeMaster.Update(oAccomTypeData);
        if (bActionCompleted == true)
        {
            txtAccomType.Text = "";
            base.DisplayAlert("The record has been updated successfully");
        }
        else if (bActionCompleted == false)
        {
            base.DisplayAlert("The record has been not been updated successfully");
            lblStatus.Text = "Error in saving.";
        }

        txtAccomType.Text = "";
        lblStatus.Text    = "Updated";
        oAccomTypeData    = null;
        oAccomTypeMaster  = null;
    }
Пример #7
0
        private AccomTypeDTO[] GetAccomodationTypesPermitted(int UserID)
        {
            string          sProcName;
            DatabaseManager oDB;

            AccomTypeDTO[] objAccomodationTypeData = null;
            try
            {
                oDB       = new DatabaseManager();
                sProcName = "up_Get_AccomodationType_New";
                oDB.DbCmd = oDB.GetStoredProcCommand(sProcName);
                oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iUserID", DbType.Int32, UserID);
                DataSet ds = oDB.ExecuteDataSet(oDB.DbCmd);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    objAccomodationTypeData = new AccomTypeDTO[ds.Tables[0].Rows.Count];
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        objAccomodationTypeData[i] = new AccomTypeDTO();
                        objAccomodationTypeData[i].AccomodationTypeId = Convert.ToInt32(ds.Tables[0].Rows[i][0]);
                        objAccomodationTypeData[i].AccomodationType   = Convert.ToString(ds.Tables[0].Rows[i][1]);
                    }
                }
            }
            catch (Exception exp)
            {
                oDB = null;
                GF.LogError("clsAccomodationMaster.GetAccomodationTypesPermitted", exp.Message);
                return(null);
            }
            finally
            {
                oDB = null;
            }
            return(objAccomodationTypeData);;
        }