当前位置: 首页>>代码示例>>C#>>正文


C# Session.CreateEntityQuery方法代码示例

本文整理汇总了C#中Session.CreateEntityQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Session.CreateEntityQuery方法的具体用法?C# Session.CreateEntityQuery怎么用?C# Session.CreateEntityQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session.CreateEntityQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SavePurchaseGroup

 void SavePurchaseGroup()
 {
     using (ISession session = new Session())
     {
         try
         {
             PurchaseGroup purchasegroup = new PurchaseGroup();
             purchasegroup.PurchGroupCode = this.txtPurchGroupCode.Text;
             purchasegroup.PurchGroupText = this.txtPurchGroupText.Text;
             if (this.IsAddNew())
             {
                 //检测code是否重复
                 int existsCount = session.CreateEntityQuery<Magic.Basis.PurchaseGroup>().Where(Magic.Framework.ORM.Query.Exp.Eq("PurchGroupCode", purchasegroup.PurchGroupCode)).Count();
                 if (existsCount > 0)
                 {
                     WebUtil.ShowMsg(this, string.Format("采购组编号{0}已经存在", purchasegroup.PurchGroupCode), "错误");
                     return;
                 }
                 purchasegroup.Create(session);
             }
             else
             {
                 purchasegroup.Update(session, "PurchGroupText");
             }
             this.Response.Redirect("PurchaseGroupManager.aspx");
         }
         catch (Exception ex)
         {
             logger.Info("保存Logistics", ex);
             WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
         }
     }
 }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:33,代码来源:PurchaseGroupEdit.aspx.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtTypeCode.Text = WebUtil.Param("type");
            if (this.txtTypeCode.Text.Trim().Length <= 0)
            {
                this.txtIsNew.Value = "1";
                this.trNeedAppr.Visible = false;
            }
            else
            {
                this.txtIsNew.Value = "";
                WebUtil.DisableControl(this.txtTypeCode);
            }
            //发货(销售发货和换货发货)由CRM生成,单据编码规则在ERP中不会起作用
            if (this.TypeCode == "SD0" || this.TypeCode == "DL2")
                this.trRule.Visible = false;

            using (ISession session = new Session())
            {
                IList<OrderRuleDef> ruleDefines = session.CreateEntityQuery<OrderRuleDef>()
                    .OrderBy("RuleDefineID")
                    .List<OrderRuleDef>();
                this.drpRule.Items.Clear();
                this.drpRule.Items.Add(new ListItem("", "0"));
                foreach (OrderRuleDef rule in ruleDefines)
                    this.drpRule.Items.Add(new ListItem(string.IsNullOrEmpty(rule.RuleDefineText) ? " " : rule.RuleDefineText, rule.RuleDefineID.ToString()));

                if (!this.IsNew)
                {
                    OrderTypeDef def = OrderTypeDef.Retrieve(session, this.TypeCode);
                    if (def != null)
                    {
                        this.txtText.Text = def.TypeText;
                        this.txtUrl.Text = def.ViewURL;
                        if (!def.SupportApprove)
                            this.trNeedAppr.Visible = false;
                        else
                            this.drpNeedAppr.SelectedValue = def.NeedApprove ? "1" : "0";
                        this.lblSupportAppr.Text = RenderUtil.FormatBool(def.SupportApprove, "是", "否");
                        if (def.RuleDefineID > 0)
                            this.drpRule.SelectedValue = def.RuleDefineID.ToString();
                    }
                }
            }
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:48,代码来源:OrderTypeDefEdit.aspx.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtDateFrom.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
            this.txtDateTo.Text = DateTime.Now.ToString("yyyy-MM-dd");

            using (ISession session = new Session())
            {
                IList<Vendor> vendors = session.CreateEntityQuery<Vendor>()
                    .OrderBy("ShortName")
                    .List<Vendor>();
                this.drpVendor.Items.Clear();
                this.drpVendor.Items.Add(new System.Web.UI.WebControls.ListItem("",""));
                foreach (Vendor v in vendors)
                    this.drpVendor.Items.Add(new System.Web.UI.WebControls.ListItem(v.ShortName, v.VendorID.ToString()));
                this.QueryAndBindData(session, 1, this.magicPagerMain.PageSize, true);
            }
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:20,代码来源:PurchaseBillingQuery.aspx.cs

示例4: MagicItemCommand

    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        using (ISession session = new Session())
        {
            bool deleted = false;
            try
            {
                session.BeginTransaction();
                foreach (RepeaterItem item in this.repeatControl.Items)
                {
                    HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                    if (chk.Checked && chk.Value.Trim().Length > 0)
                    {
                        RCVHead head = RCVHead.Retrieve(session, chk.Value.Trim());
                        if (head == null || head.Status != ReceiveStatus.New) continue;

                        head.Delete(session);
                        session.CreateEntityQuery<RCVLine>()
                            .Where(Exp.Eq("OrderNumber", head.OrderNumber))
                            .Delete();
                        deleted = true;
                    }
                }

                session.Commit();
                if (deleted)
                {
                    WebUtil.ShowMsg(this, "ѡ����ջ����Ѿ�ɾ��");
                    this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
                }
            }
            catch (Exception er)
            {
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:38,代码来源:PurchaseRCVManage.aspx.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtId.Value = WebUtil.Param("ordNumber");

            StockInHead head = null;
            using (ISession session = new Session())
            {
                IList<WHLocation> locations = session.CreateEntityQuery<WHLocation>()
                    .Where(Magic.Framework.ORM.Query.Exp.Eq("Status", WHStatus.Enable))
                    .OrderBy("LocationCode")
                    .List<WHLocation>();
                this.drpLocation.Items.Clear();
                foreach (WHLocation loc in locations)
                    this.drpLocation.Items.Add(new ListItem(loc.Name, loc.LocationCode));

                head = StockInHead.Retrieve(session, this.OrderNumber);
                this.showInfo(session, head);
            }
            this.setView(head);
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:23,代码来源:ProductInEdit.aspx.cs

示例6: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtAction.Value = WebUtil.Param("mode");
            this.txtId.Value = WebUtil.Param("ordNumber");

            ICHead head = null;
            using (ISession session = new Session())
            {
                IList<Logistics> companies = session.CreateEntityQuery<Logistics>()
                    .Where(Magic.Framework.ORM.Query.Exp.Eq("Status", LogisticsStatus.Enable))
                    .OrderBy("ShortName")
                    .List<Logistics>();
                this.drpLogistic.Items.Clear();
                foreach (Logistics lg in companies)
                    this.drpLogistic.Items.Add(new ListItem(lg.ShortName, lg.LogisticCompID.ToString()));

                if (!this.IsNew)
                {
                    head = ICHead.Retrieve(session, this.OrderNumber);
                    this.showInfo(session, head);
                }
            }
            this.setView(head);
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:27,代码来源:InterchangeEdit.aspx.cs

示例7: MagicItemCommand

    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName != "Save" && e.CommandName != "Delete")
        {
            WebUtil.ShowError(this, "��������");
            return;
        }
        if (this.repeatControl.Items.Count <= 0) return;

        IList<OrderApproveDef> defines = new List<OrderApproveDef>();
        foreach (RepeaterItem item in this.repeatControl.Items)
        {
            HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
            if (e.CommandName == "Delete" && chk.Checked) continue;
            HtmlInputText txt = item.FindControl("txtSeq") as HtmlInputText;
            int userId = Magic.Framework.Utils.Cast.Int(chk.Value, -1);
            if (userId <= 0)
            {
                WebUtil.ShowError(this, "�޷���ȡǩ���û����ϣ���͹���Ա��ϵ");
                return;
            }

            OrderApproveDef def = new OrderApproveDef();
            def.OrderTypeCode = this.OrderTypeCode;
            def.UserID = userId;
            def.UserSequnce = Magic.Framework.Utils.Cast.Int(txt.Value);
            defines.Add(def);
        }

        using (ISession session = new Session())
        {
            try
            {
                session.BeginTransaction();
                session.CreateEntityQuery<OrderApproveDef>()
                    .Where(Exp.Eq("OrderTypeCode", this.OrderTypeCode))
                    .Delete();
                this.SortDefines(defines);
                for (int i = 1; i <= defines.Count; i++)
                {
                    defines[i-1].StepIndex = i;
                    defines[i-1].Create(session);
                }
                session.Commit();
                if (e.CommandName == "Save")
                    WebUtil.ShowMsg(this, "ǩ��˳�򱣴�ɹ�");
                else
                    WebUtil.ShowMsg(this, "ѡ���ǩ����Ա�Ѿ�ɾ��");
                this.QueryAndBindData(session);
            }
            catch (Exception er)
            {
                session.Rollback();
                WebUtil.ShowError(this, er);
            }
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:57,代码来源:ApproveDefUser.aspx.cs

示例8: QueryAndBindData

    /// <summary>
    /// Get query conditions from page , and query data from db, then bind the query result to Repeater
    /// </summary>
    private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount)
    {
        string name = txtName.Text.Trim();
        string description = txtDescription.Text.Trim();
        IList<string> groupType = WebUtil.GetSelectedValues(cklGroupType);
        string modifyTime = txtModifyTime.Text.Trim();

        IList<UserGroup> dataUserGroup = null;

        int recordCount = 0;

        using (Session session = new Session())
        {
            EntityQuery query = session.CreateEntityQuery<UserGroup>();

           	if(!String.IsNullOrEmpty(name))
            {
                query.And(Exp.Like("Name", "%" + name+ "%"));
            }
           	if(!String.IsNullOrEmpty(description))
            {
                query.And(Exp.Like("Description", "%" + description+ "%"));
            }
           	if(groupType != null && groupType.Count > 0)
            {
                query.And(Exp.In("GroupType", groupType));
            }
           	if(!String.IsNullOrEmpty(modifyTime))
            {
                query.And(Exp.Eq("ModifyTime", modifyTime));
            }

            query.SetPage(pageIndex, pageSize);

             dataUserGroup = query.List<UserGroup>();

            if (fetchRecordCount)
                recordCount = query.Count();
        }
        this.rptUserGroup.DataSource = dataUserGroup ;
        this.rptUserGroup.DataBind();

        if (fetchRecordCount)
        {
            this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount;
        }

        WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
        WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);

        //After a query, save current query
        this.hidReturnUrl.Value = GetReturnUrl();
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:56,代码来源:UserGroupList.aspx.cs

示例9: SaveUser4Page

    private void SaveUser4Page()
    {
        using (Session session = new Session())
        {
            try
            {
                User user = new User();
                user.UserName = this.txtUserName.Text.Trim();
                user.Password = this.txtPassword.Text;
                user.Email = txtEmail.Text.Trim();
                user.Ext = txtExt.Text.Trim();
                user.FullName = txtFullName.Text.Trim();
                if(Org.UseDefaultOrg(session))
                    user.OrgId = Org.DefaultOrg(session);
                else
                    user.OrgId = Cast.Int(this.txtOrgId.Text, -1);
                user.Status = Cast.Enum<UserStatus>(this.rblStatus.SelectedValue);
                user.UserType = Cast.Enum<OrgType>(this.ddlUserType.SelectedValue);
                user.ModifyBy = SecuritySession.CurrentUser.UserId;
                user.ModifyTime = DateTime.Now;

                if (IsAddNew())
                {
                    //检查帐号是否重复
                    int existsUserCount = session.CreateEntityQuery<Magic.Sys.User>()
                        .Where(Magic.Framework.ORM.Query.Exp.Eq("UserName", user.UserName))
                        .Count();
                    if (existsUserCount > 0)
                    {
                        WebUtil.ShowMsg(this, string.Format("用户帐号{0}已经存在", user.UserName), "错误");
                        return; //这里的return语句,using会保证session释放
                    }
                    //UserId是自增长主键,新增时不要设置它的值,新增完毕后框架会自动设置好这个值
                    user.CreateBy = SecuritySession.CurrentUser.UserId;
                    user.CreateTime = DateTime.Now;
                    user.Create(session);
                }
                else
                {
                    user.UserId = Cast.Int(this.txtUserId.Value, -1); //UserId是主键,更新时需要设置
                    user.Update(session, "Email", "Ext", "FullName", "OrgId", "Password", "Status", "UserType", "ModifyBy", "ModifyTime");
                }
                this.txtUserId.Value = user.UserId.ToString(); //如果是新增用户,新增完毕后将用户ID设置到以页面隐藏控件(新增后UserId已经被赋值了)
                WebUtil.ShowMsg(this, "用户保存成功", "操作成功");
            }
            catch (Exception ex)
            {
                logger.Info("保存User", ex);
                WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
            }
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:52,代码来源:UserEdit.aspx.cs

示例10: mbar_ItemCommand

    protected void mbar_ItemCommand(object sender, Magic.Web.UI.MagicItemEventArgs args)
    {
        if (args.CommandName == "save")
        {
            using (ISession session = new Session())
            {
                try
                {
                    string itemCode = this.txtItemCode.Text.Trim();
                    string itemStatus = this.ddlItemStatus.SelectedValue;
                    string itemName = this.txtItemName.Text.Trim();
                    string itemDesc = this.txtItemSpec.Text.Trim();
                    if (this.IsNew)
                    {
                        //新增
                        ItemMaster master = new ItemMaster();
                        master.ItemCode = itemCode;
                        //判断输入的itemCode是否重复
                        if (session.CreateEntityQuery<ItemMaster>().Where(Exp.Eq("ItemCode", itemCode)).Count() > 0)
                        {
                            WebUtil.ShowMsg(this, string.Format("辅料编号{0}已经存在", master.ItemCode), "错误");
                            return;
                        }
                        master.ItemType = ItemType.AssistantItem;
                        master.ItemName = itemName;
                        master.ItemDesc = itemDesc;
                        session.BeginTransaction();
                        master.Create(session);
                        ItemSpec spec = new ItemSpec();
                        spec.ItemID = master.ItemID;
                        spec.ItemCode = itemCode;
                        spec.Status = Cast.Enum<ItemSpecStatus>(itemStatus);
                        spec.ColorCode = " ";
                        spec.BarCode = itemCode;
                        spec.OperateTime = DateTime.Now;
                        spec.Operator = 0;// Magic.Security.SecuritySession.CurrentUser.UserId;
                        spec.PubDate = DateTime.Now;
                        spec.AvgMoveCost = 0;
                        spec.EnableCost = true;
                        spec.EnableOS = false;
                        spec.Create(session);
                        session.Commit();
                    }
                    else
                    {
                        session.BeginTransaction();
                        ItemSpec spec = ItemSpec.Retrieve(session, this.SKUID);
                        spec.Status = Cast.Enum<ItemSpecStatus>(itemStatus);
                        spec.Update(session, "Status");

                        int itemID = spec.ItemID;
                        ItemMaster master = ItemMaster.Retrieve(session, itemID);
                        master.ItemName = itemName;
                        master.ItemDesc = itemDesc;
                        master.Update(session, "ItemName", "ItemDesc");
                        session.Commit();
                    }
                }
                catch (System.Exception e)
                {
                    session.Rollback();
                    throw e;
                }
            }

            this.Response.Redirect(WebUtil.Param("return"));
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:68,代码来源:ASSItemEdit.aspx.cs

示例11: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.txtStartDate.Value = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd");
            this.txtEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            using (ISession session = new Session())
            {
                WebUtil.SetMagicPager(magicPagerMain, magicPagerMain.PageSize, 1);
                WebUtil.SetMagicPager(magicPagerSub, magicPagerMain.PageSize, 1);

                this.drpVendor.Items.Clear();
                this.drpVendor.Items.Add(new ListItem(" ", "0"));
                IList<Vendor> vendors = session.CreateEntityQuery<Vendor>()
                    .List<Vendor>();
                foreach (Vendor v in vendors)
                    this.drpVendor.Items.Add(new ListItem(v.ShortName, v.VendorID.ToString()));

                OrderTypeDef orderTypeDef = OrderTypeDef.Retrieve(session, POHead.ORDER_TYPE);
                if (orderTypeDef != null)
                    this.hidViewUrl.Value = orderTypeDef.ViewURL;
                RestoreLastQuery(session);
            }
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:25,代码来源:POManager.aspx.cs

示例12: ValidateUser

        /// <summary>
        /// 验证用户,并返回合法用户的
        /// </summary>
        /// <param name="session"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="validUser"></param>
        /// <returns>true:通过,false:不通过</returns>
        private bool ValidateUser(string userName, string password, out UserBase validUser)
        {
            validUser = null;

            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("UserName and Password can not be NULL!");
            }
            using (ISession session = new Session())
            {
                IList<Magic.Sys.User> list = session.CreateEntityQuery<Magic.Sys.User>()
                .And(Exp.Eq("UserName", userName))
               // .And(Exp.Eq("Password", Magic.Security.Utility.Encryption.MD5(password, 32)))
               .And(Exp.Eq("Password",password))
                .List<User>();

                if (list == null || list.Count == 0)
                {
                    return false;
                }

                validUser = list[0];
                return true;
            }
        }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:33,代码来源:FormAuthenticateService.cs

示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.cmdReturn1.Visible = false;
            this.cmdReturn2.Visible = false;

            this.txtDateFrom.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
            this.txtDateTo.Text = DateTime.Now.ToString("yyyy-MM-dd");

            this.drpPeriod.Items.Clear();
            this.drpPeriod.Items.Add(new ListItem(" ", "0"));
            this.drpLogis.Items.Clear();
            this.drpLogis.Items.Add(new ListItem(" ", "0"));
            using (ISession session = new Session())
            {
                IList<INVPeriod> periods = INVPeriod.ClosedPeriods(session);
                foreach (INVPeriod p in periods)
                    this.drpPeriod.Items.Add(new ListItem(p.PeriodCode, p.PeriodID.ToString()));
                if (this.drpPeriod.Items.Count > 1)
                    this.drpPeriod.SelectedIndex = 1;
                IList<Logistics> logis = session.CreateEntityQuery<Logistics>()
                    .OrderBy("ShortName")
                    .List<Logistics>();
                foreach (Logistics lg in logis)
                    this.drpLogis.Items.Add(new ListItem(lg.ShortName, lg.LogisticCompID.ToString()));

                string mode = WebUtil.Param("mode");
                if (mode.Trim().ToLower() == "fix")
                {
                    //从销售款统计导航过来
                    this.cmdReturn1.Visible = true;
                    this.cmdReturn2.Visible = true;
                    this.cmdReturn1["Return"].NavigateUrl = this.cmdReturn2["Return"].NavigateUrl = WebUtil.Param("return");

                    this.drpPeriod.SelectedValue = WebUtil.ParamInt("pd", 0).ToString();
                    int logisId = WebUtil.ParamInt("lg", 0);
                    if (logisId < 0) logisId = 0;
                    this.drpLogis.SelectedValue = logisId.ToString();
                    DateTime dt;
                    dt = Cast.DateTime(WebUtil.Param("df"), new DateTime(1900, 1, 1));
                    if (dt > new DateTime(1900, 1, 1))
                        this.txtDateFrom.Text = dt.ToString("yyyy-MM-dd");
                    dt = Cast.DateTime(WebUtil.Param("dt"), new DateTime(1900, 1, 1));
                    if (dt > new DateTime(1900, 1, 1))
                        this.txtDateTo.Text = dt.ToString("yyyy-MM-dd");
                }

                this.RestoreLastQuery(session);
            }
        }
        else this.frameDownload.Attributes["src"] = "about:blank;";
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:53,代码来源:SaleAmtDetail.aspx.cs

示例14: CacheUser

 public static void CacheUser()
 {
     if (!_cached && _userNameHash.Count == 0)
     {
         using (ISession session = new Session())
         {
             IList<User> users = session.CreateEntityQuery<User>()
                 .And(Exp.Eq("USR_STATUS", UserStatus.Enabled))
                 .List<User>();
             if (users != null && users.Count > 0)
             {
                 foreach (User user in users)
                 {
                     _userNameHash.Add(user.UserId, user.FullName);
                 }
             }
         }
         _cached = true;
     }
 }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:20,代码来源:User.cs

示例15: SaveWHLoc

 private static SimpleJson SaveWHLoc()
 {
     string type = WebUtil.Param("type");
     if (type != "l" && type != "a" && type != "s")
         return new SimpleJson()
             .HandleError(string.Format("Invalidate type {0} in action SaveWHLoc", type));
     string opt = WebUtil.Param("opt");
     if (opt != "create" && opt != "update")
         return new SimpleJson()
             .HandleError("Invalidate operation in action SaveWHLoc");
     if (WebUtil.Param("code").Trim().Length <= 0)
         return new SimpleJson()
             .HandleError("Invalidate code in action SaveWHLoc");
     using (ISession session = new Session())
     {
         if (type == "l")
         {
             #region WHLocation
             WHLocation location = new WHLocation();
             location.LocationCode = WebUtil.Param("code").Trim();
             location.Name = WebUtil.Param("name").Trim();
             location.Status = Cast.Enum<WHStatus>(WebUtil.ParamInt("status", 1));
             location.Text = WebUtil.Param("desc").Trim();
             location.Address = WebUtil.Param("addr").Trim();
             location.ZipCode = WebUtil.Param("zipcode").Trim();
             location.Contact = WebUtil.Param("contact");
             location.Phone = WebUtil.Param("phone").Trim();
             location.FaxNumber = WebUtil.Param("fax").Trim();
             location.CompanyID = WebUtil.ParamInt("comp", 0);
             if (opt == "create")
             {
                 if (session.CreateEntityQuery<WHLocation>().Where(Exp.Eq("LocationCode", location.LocationCode)).Count() > 0)
                     return new SimpleJson().HandleError(string.Format("仓库代码{0}已经存在", location.LocationCode));
                 location.Create(session);
             }
             else
                 location.Update(session);
             return location.GetJSON();
             #endregion
         }
         else if (type == "a")
         {
             #region WHArea
             if (WebUtil.Param("parent").Trim().Length <= 0)
                 return new SimpleJson().HandleError("Invalidate parent in action SaveWHLoc");
             string parentType = WebUtil.Param("parentType");
             if (parentType != "l" && parentType != "a")
                 return new SimpleJson().HandleError("Invalidate parentType in action SaveWHLoc");
             WHArea area = new WHArea();
             WHArea parentArea = null;
             area.AreaCode = WebUtil.Param("code").Trim();
             if (parentType == "l") area.LocationCode = WebUtil.Param("parent").Trim();
             else
             {
                 parentArea = WHArea.Retrieve(session, WebUtil.Param("parent").Trim());
                 if (parentArea == null)
                     return new SimpleJson().HandleError(string.Format("Parent {0} not found", WebUtil.Param("parent").Trim()));
                 area.LocationCode = parentArea.LocationCode;
                 area.ParentArea = parentArea.AreaCode;
             }
             area.Name = WebUtil.Param("name").Trim();
             area.Text = WebUtil.Param("desc").Trim();
             area.Status = Cast.Enum<WHStatus>(WebUtil.ParamInt("status", 1));
             area.AreaCapacity = WebUtil.ParamDecimal("cap", 99999999M);
             area.HasSection = WebUtil.Param("hassec").Trim() == "1" ? true : false;
             area.IsQC = WebUtil.Param("isqc").Trim() == "1" ? true : false;
             area.IsScrap = WebUtil.Param("isscrap").Trim() == "1" ? true : false;
             if (opt == "create")
             {
                 if (session.CreateEntityQuery<WHArea>().Where(Exp.Eq("AreaCode", area.AreaCode)).Count() > 0)
                     return new SimpleJson().HandleError(string.Format("存储区域代码{0}已经存在", area.AreaCode));
                 if (parentArea != null)
                 {
                     area.CostTransRate = parentArea.CostTransRate;
                     area.CostFixValue = parentArea.CostFixValue;
                     area.UseFixCost = parentArea.UseFixCost;
                     area.AllowChild = true;
                     area.AllowDelete = true;
                     area.IsReservedArea = false;
                     area.IsTransArea = parentArea.IsTransArea;
                 }
                 else
                 {
                     area.CostTransRate = 1M;
                     area.CostFixValue = 0M;
                     area.UseFixCost = false;
                     area.AllowChild = true;
                     area.AllowDelete = true;
                     area.IsReservedArea = false;
                     area.IsTransArea = true;
                 }
                 area.Create(session);
             }
             else
             {
                 area.Update(session, "Name", "Text", "Status", "AreaCapacity", "HasSection", "IsQC", "IsScrap");
             }
             return area.GetJSON();
             #endregion
         }
//.........这里部分代码省略.........
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:101,代码来源:MagicAjax.cs


注:本文中的Session.CreateEntityQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。