Пример #1
0
        /// <summary>
        /// Bind Agent grid
        /// </summary>
        private void BindGrid()
        {
            objAgentLookup = new AgentDal();
            DataSet dsAgent = objAgentLookup.GetAgent("");
            radgrdAgent.DataSource = dsAgent;
            radgrdAgent.DataBind();
            ViewState[vsAgent] = dsAgent;

        }
Пример #2
0
        protected void acbAgent_SearchClick(object sender, EventArgs e)
        {
            try
            {

                objAgentLookup = new AgentDal();
                DataSet dsAgent = objAgentLookup.GetAgent(acbAgent.SearchTextBox.Text);
                radgrdAgent.DataSource = dsAgent;
                radgrdAgent.DataBind();
                ViewState[vsAgent] = dsAgent;
                Reset();
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }

        }
Пример #3
0
        protected void acbAgent_SaveClick(object sender, EventArgs e)
        {
            try
            {
                int result = 0;
                objAgentLookup = new AgentDal();
                switch (acbAgent.SaveButton.CommandName)
                {
                    case "Save":
                        Save();
                        pnlAddNewMode.Visible = false;
                        acbAgent.EditableMode = false;

                        break;

                    case "Update":
                        String xmlData = GenerateXmlString(radgrdAgent);
                        result = objAgentLookup.UpdateAgent(xmlData);
                        if (result == 1)
                        {
                            acbAgent.DefaultMode = true;
                            Master.DisplayMessage(ConfigurationSettings.AppSettings["UpdateRecord"].ToString());
                            Master.MessageCssClass = "successMessage";

                            if (ViewState[PageConstants.vsItemIndexes] != null)
                                htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];
                            for (int i = 0; i < htItemIndex.Count; i++)
                                radgrdAgent.Items[Convert.ToInt32(htItemIndex[i])].Edit = false;
                            bisEdit = false;
                            ViewState[PageConstants.vsItemIndexes] = null;
                            BindGrid();
                        }
                        else
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Update].ToString());
                            Master.MessageCssClass = "errorMessage";
                        }
                        break;
                }
                //objAgentBDto = new AgentDal();

            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }
        }
Пример #4
0
        protected void acbAgent_DeleteClick(object sender, EventArgs e)
        {
            try
            {
                StringBuilder AgentId = new StringBuilder();
                int result = 0;
                if (ViewState[PageConstants.vsItemIndexes] != null)
                    htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];

                if (htItemIndex != null)
                {
                    foreach (int i in htItemIndex.Values)
                    {
                        Label lblAgentId = (Label)radgrdAgent.Items[i].FindControl("lblgrdAgentIdItem");

                        if (lblAgentId != null)
                        {
                            AgentId.Append(lblAgentId.Text + ",");
                        }
                    }
                }


                objAgentLookup = new AgentDal();
                String AgeId = AgentId.ToString().TrimEnd(',');
                result = objAgentLookup.DeleteAgent(AgeId);


                if (result == 1)
                {
                    Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Delete].ToString());
                    Master.MessageCssClass = "successMessage";
                    ViewState[PageConstants.vsItemIndexes] = null;
                    BindGrid();
                }
                else if (result == 547)
                {
                    Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Delete].ToString());
                    Master.MessageCssClass = "errorMessage";
                }
            }


            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }
        }
Пример #5
0
        private void Save()
        {
            try
            {
                int result = 0;
                objAgentLookup = new AgentDal();
                objAgentBDto = new AgentBDto();
                objAgentBDto.AgentName = txtAgentName.Text;
                objAgentBDto.Email = txtEmail.Text;
                objAgentBDto.Mobile = txtMobile.Text;
                objAgentBDto.Phone = txtPhone.Text;
                objAgentBDto.Fax = txtFax.Text;

                objAgentBDto.UserId = objAuthorizationBDto.UserProfile.UserId;
                result = objAgentLookup.InsertAgent(objAgentBDto);
                if (result >= 1)
                {
                    Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Save].ToString());
                    Master.MessageCssClass = "successMessage";
                    bisEdit = false;
                }
                else
                {
                    Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Save].ToString());
                    Master.MessageCssClass = "errorMessage";
                }
                BindGrid();
                Reset();
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }
        }