Sage CRM SDK 开发

来源:互联网 发布:纽约房价 知乎 编辑:程序博客网 时间:2024/06/05 14:31

引用:

    using Sage.CRM.WebObject;
    using Sage.CRM.Blocks;
    using Sage.CRM.Controls;
    using Sage.CRM.Data;
    using Sage.CRM.HTML;
    using Sage.CRM.Utils;

常规新建内容:

        AddContent(HTML.Form());
            string hmode = Dispatch.EitherField("HiddenMode");
            EntryGroup myscreen = Metadata.GetScreen("OEPriceNewEntry");
            if (hmode == "Save")
            {
                Record myRec = CreateRecord("OEPrice");
                myscreen.FillEntityFromContent(myRec);
                myRec.SaveChanges();
                Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunOEPriceDataPage"));
            }
            else
            {
                AddContent(HTML.StartTable());
                AddContent(HTML.InputHidden("HiddenMode", ""));
                AddContent(HTML.BoxTitle(Metadata.GetTranslation("Tabnames", "New Record")));
                AddContent(HTML.BoxContent(myscreen.GetHtmlInEditMode()));
                string sUrl = "javascript:document.EntryForm.HiddenMode.value='Save';";
                AddSubmitButton("Save", "Save.gif", sUrl);
                //AddUrlButton("Cancel", "Cancel.gif", UrlDotNet(ThisDotNetDll, "RunCaseFailureTyreList"));
                AddContent(HTML.EndTable());
            }

执行sql语句:

    string UpdateSql = "update failuretyre Set ft_yn='Y' where  t_failuretyreid in (" + Fyid + ")";
        QuerySelect iUpdate = GetQuery();
        iUpdate.SelectSql(UpdateSql);
       
页面转向:

    Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunCaseFailureTyreList"));

添加选项卡:

    在BuildContent()中使用GetTabs("……");

获取值:

    string caseid = Dispatch.EitherField("case_caseid");

获取传入值:

    string stroepriceID;
        if (Dispatch.ContentField("oep_oepriceID") == null)
        {
            stroepriceID = Dispatch.ContentField("key58");
        }
        else
        {
           stroepriceID = Dispatch.ContentField("oep_oepriceID");
        }

清除内容开头和结束位置的空白字符:

    Fyid = Fyid.Trim();

设置页面某一项只读,内容默认:

     EntryGroups myscreen = Metadata.GetScreen("FYPlanNewEntry");
         Entry myentry = myscreen.GetEntry("FYP_Secterr");
         myentry.ReadOnly = true;
         myentry.DefaultValue = 0;
--注:当发现更改默认值无效时,可尝试设置 myentry.DefaultType = 1;

页面添加表格:

    List MpitemList = Metadata.GetList("OEPItemGrid");
    AddContent(HTML.StartTable());
        AddContent(HTML.BoxTitle(Metadata.GetTranslation("Tabnames", "Oepitem")));
        AddContent(HTML.GridData(MpitemList.GetViewHtml("oepi_oepriceid=" + stroepriceID)));
        AddContent(HTML.EndTable());

查找记录:

    Record recOeprice = FindRecord("OEPrice", "oep_deleted is null and oep_oepriceID=" + stroepriceID);

从记录中获取某一项的值:

    recOeprice.GetFieldAsString("oep_status").Trim()

判断当前用户是否有某一数据表的某一操作权限:

    if (CurrentUser.HasRights(Sage.PermissionType.Insert, "Oeprice"))//该句是判断当前用户是否有对数据表“Oeprice”有插入数据权限
    {
            AddUrlButton("ContinueNew", "Continue.gif", UrlDotNet(ThisDotNetDll, "RunOEPRiceNew"));
        }
    if (CurrentUser.IsInRange(Sage.PermissionType.Delete, "OEPrice", TerritoryId, AssignedToUserId, AssignedToTeamId, CreatedByUserId))
        {
           AddUrlButton("Delete", "Delete.gif", UrlDotNet(ThisDotNetDll, "RunOEPRiceDelete"));
           }

获取原先查找条件语句,从而显示相应内容列表

    EntryGroup OFind = SearchScreen;//该页面继承了SearchPage ,元数据中定义了SearchScreen ,所以此举为获取原先定义的EntryGroup
    string mysql;
        if ((CurrentUser.UserId == 87) || (CurrentUser.UserId == 158) || (CurrentUser.UserId == 1))
        {
           if (OFind.GetSqlForSearch() == "")
           {                       
              mysql = "Oep_status='Active'";
           }
           else
           {
              mysql = OFind.GetSqlForSearch();
           }
           AddContent(HTML.GridData(OEPriceGrid.GetViewHtml(mysql)));
        }
        else
        {
              if (OFind.GetSqlForSearch() == "")
              {
                 mysql = "Oep_status='Active'";
              }
              else
              {
                 mysql = OFind.GetSqlForSearch() + "and Oep_status='Active'";
              }
              AddContent(HTML.GridData(OEPriceGrid.GetViewHtml(mysql)));
       }

设置字段的值:

    recOepricenew.SetField("oep_preid", recOeprice.RecordId);
        recOepricenew.SaveChanges();

记录循环:

     while (!recoepitem.Eof())//recoepitem.Eof()中Eof应该是 End of 的意思 该方法返回的应是 记录是否已到最后的意思 到最后返回True
         {
        recoepitem.GoToNext();//到下一条
         }

当前用户登录ID:

     this.CurrentUser.UserId

选择连动
    myentry1.OnChangeScript = "javascript:document.getElementById('FYP_shi').romove(1);document.EntryForm.HiddenMode.value='changed';self.EntryForm.submit();";

原创粉丝点击