예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "Panoply Technologies";

        Master.setMenuIndex(2);
        Master.requiresAuthentication = true;
        if (!this.securityLayer())
        {
            return;
        }
        string compid = SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid");
        string persid = SageCRMPortalEntryBlock.GetVisitorInfo("pers_personid");

        SageCRMPortalEntryBlock.EntityWhere = "comp_companyid=" + compid;
        lbl_companyinfo.Text = "Below is your company information that we contain on our databse.<br />" +
                               "<br />Please verify the information to help us ensure that it is up to date." +
                               "<br />Only the primary contact in your company can edit this data." +
                               "";
        SageCRMDataSource1.TableName   = "Company";
        SageCRMDataSource1.WhereClause = "comp_companyid=" + compid;
        IDataReader idr = SageCRMDataSource1.SelectData();

        //only the primaru person can edit the company information
        idr.Read();
        string ppersid = idr["comp_primarypersonid"] as string;

        if (ppersid != persid)
        {
            Button1.Visible = false;
        }
        else
        {
            Button1.Visible = true;
        }
    }
 protected void SageCRMPortalEntryBlock_BeforeRendering(object source, ref string HTMLSource)
 {
     //extract the new record id...
     //when createrecord mode is set and a new record created
     //the Entryblock returns "<recordid>newid</recordid>"....
     //eg "<recordid>123</recordid>"
     if (HTMLSource.StartsWith("<recordid>") == true)
     {
         //parse out the new record id.
         //You could possibly parse out this using some xml objects
         int iEnd = HTMLSource.IndexOf("</recordid>");
         caseid = HTMLSource.Substring(10, iEnd - 10);
         //update the record with the default values
         SageCRMDataSource2.WhereClause = "case_caseid=" + caseid;
         SageCRMDataSource2.Parameters.Add("case_primarycompanyid", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));
         SageCRMDataSource2.Parameters.Add("case_primarypersonid", SageCRMPortalEntryBlock.GetVisitorInfo("pers_personid"));
         SageCRMDataSource2.Parameters.Add("case_source", "Web");
         SageCRMDataSource2.Parameters.Add("case_stage", "Logged");
         SageCRMDataSource2.Parameters.Add("case_priority", "Normal");
         SageCRMDataSource2.Parameters.Add("case_status", "In Progress");
         SageCRMDataSource2.UpdateRecord();
         //redirect to the details page with the new id
         Response.Redirect("casedetail.aspx?case_caseid=" + caseid);
     }
 }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (!this.FileUpload1.HasFile)
        {
            return;
        }

        //this.FileUpload1.SaveAs(@"C:\\Program Files\\Sage\\CRM\\CRM62sp1\\Library\\" + FileUpload1.FileName.ToString());
        string path = getPath(FileUpload1.FileName.ToString());

        this.FileUpload1.SaveAs(@path);

        //create library record
        SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
        ds.SageCRMConnection = this.SageCRMDataSource2.SageCRMConnection;
        ds.TableName         = "Library";
        ds.Parameters.Add("libr_caseid", this.caseid);
        ds.Parameters.Add("libr_personid", SageCRMPortalEntryBlock.GetVisitorInfo("pers_personid"));
        ds.Parameters.Add("libr_companyid", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));
        string folderpath = getLibrFolder("company", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));

        ds.Parameters.Add("libr_filepath", folderpath);
        ds.Parameters.Add("libr_filename", this.FileUpload1.FileName.ToString());
        ds.Parameters.Add("libr_note", this.libr_note.Text.ToString());
        //Label1.Text= ds.InsertRecord();
        ds.InsertRecord();
    }
    public string getPath(string fname)
    {
        string FilePath = getLibrFolder("company", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));
        //now save the contents to the file path
        string path     = getDocStore() + "\\" + FilePath + "\\";
        string fullpath = path + fname;

        //make sure the folder exists
        folderCheck(fullpath);
        //make sure that we have a unique filename
        fullpath = GetUniqueFilename(fullpath);
        return(fullpath);
    }