示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text      = string.Empty;
            lblError.Visible   = false;
            lblSave.Text       = string.Empty;
            lblSave.Visible    = false;
            lblMessage.Visible = false;
            lblMessage.Text    = string.Empty;

            int clientID = Core.SessionHelper.getClientId();

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    bool exists = LeadSourceManager.IsExist(txtLeadSource.Text.Trim(), Convert.ToInt32(hdId.Value));
                    if (exists)
                    {
                        lblMessage.Text    = "Lead Source already exists!";
                        lblMessage.Visible = true;
                        txtLeadSource.Focus();
                        return;
                    }

                    LeadSourceMaster lSource = LeadSourceManager.GetLeadSourceId(Convert.ToInt32(hdId.Value));
                    lSource.LeadSourceName = txtLeadSource.Text;
                    lSource.ClientId       = clientID;
                    lSource.Status         = true;

                    LeadSourceManager.Save(lSource);

                    lblSave.Text = hdId.Value == "0" ? "Lead Source saved successfully." : "Lead Source updated successfully.";
                    btnCancel_Click(null, null);
                    lblSave.Visible = true;
                    scope.Complete();
                }
                clearFields();
            }
            catch (Exception ex) {
                lblError.Visible = true;
                lblError.Text    = "Lead Source not saved!";

                Core.EmailHelper.emailError(ex);
            }
        }
示例#2
0
        private void copyLeadSource(int sourceClientID, int targetClientID, int userID)
        {
            List <LeadSourceMaster> sources   = LeadSourceManager.GetAll(sourceClientID);
            LeadSourceMaster        newSource = null;

            if (sources != null)
            {
                foreach (LeadSourceMaster source in sources)
                {
                    newSource                = new LeadSourceMaster();
                    newSource.ClientId       = targetClientID;
                    newSource.InsertBy       = userID;
                    newSource.InsertDate     = DateTime.Now;
                    newSource.LeadSourceName = source.LeadSourceName;
                    newSource.Status         = source.Status;

                    LeadSourceManager.Save(newSource);
                }
            }
        }
示例#3
0
        protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            lblError.Text      = string.Empty;
            lblSave.Text       = string.Empty;
            lblMessage.Text    = string.Empty;
            lblMessage.Visible = false;
            lblError.Visible   = false;
            lblSave.Visible    = false;
            if (e.CommandName.Equals("DoEdit"))
            {
                int leadSourceId = Convert.ToInt32(e.CommandArgument);
                hdId.Value = leadSourceId.ToString();

                LeadSourceMaster leadSource = LeadSourceManager.GetLeadSourceId(leadSourceId);
                if (leadSource != null)
                {
                    txtLeadSource.Text = leadSource.LeadSourceName;
                }
            }
            else if (e.CommandName.Equals("DoDelete"))
            {
                // In Case of delete
                try {
                    var lSource = LeadSourceManager.GetLeadSourceId(Convert.ToInt32(e.CommandArgument));
                    lSource.Status = false;
                    LeadSourceManager.Save(lSource);
                    btnCancel_Click(null, null);
                    lblSave.Text    = "Lead Source deleted successfully.";
                    lblSave.Visible = true;
                }
                catch (Exception ex) {
                    lblError.Text    = "Lead Source not deleted!";
                    lblError.Visible = true;

                    Core.EmailHelper.emailError(ex);
                }
            }
        }