Exemplo n.º 1
0
        private void GetEntity(HttpContext context)
        {
            var    manager = new CASE_PRODUCTINFOManager(this.dbProvider, Utils.UserInfo);
            string keyId   = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("key"));
            var    entity  = manager.GetEntity(keyId);

            context.Response.Write(JSONhelper.ToJson(entity));
        }
Exemplo n.º 2
0
        private void SubmitForm(HttpContext context)
        {
            try
            {
                string   returnValue = string.Empty;
                string   msg         = RDIFrameworkMessage.MSG3020;
                var      isSuccess   = false;
                var      key         = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("key"));
                var      json        = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("json"));
                UserInfo curUser     = Utils.UserInfo;
                var      entity      = JsonHelper.JSONToObject <CASE_PRODUCTINFOEntity>(json);
                if (string.IsNullOrEmpty(key))  //增加
                {
                    var manager = new CASE_PRODUCTINFOManager(this.dbProvider, curUser);
                    returnValue = manager.Add(entity);
                    if (!string.IsNullOrEmpty(returnValue))
                    {
                        msg       = RDIFrameworkMessage.MSG0009;
                        isSuccess = true;
                    }

                    context.Response.Write(new JsonMessage {
                        Success = isSuccess, Data = returnValue, Message = msg
                    }.ToString());
                }
                else
                {
                    var manager      = new CASE_PRODUCTINFOManager(this.dbProvider, curUser);
                    var updateEntity = manager.GetEntity(key);
                    if (updateEntity != null)
                    {
                        updateEntity.PRODUCTCODE          = entity.PRODUCTCODE;
                        updateEntity.PRODUCTNAME          = entity.PRODUCTNAME;
                        updateEntity.PRODUCTMODEL         = entity.PRODUCTMODEL;
                        updateEntity.PRODUCTSTANDARD      = entity.PRODUCTSTANDARD;
                        updateEntity.PRODUCTCATEGORY      = entity.PRODUCTCATEGORY;
                        updateEntity.PRODUCTUNIT          = entity.PRODUCTUNIT;
                        updateEntity.MIDDLERATE           = entity.MIDDLERATE;
                        updateEntity.REFERENCECOEFFICIENT = entity.REFERENCECOEFFICIENT;
                        updateEntity.PRODUCTPRICE         = entity.PRODUCTPRICE;
                        updateEntity.WHOLESALEPRICE       = entity.WHOLESALEPRICE;
                        updateEntity.PROMOTIONPRICE       = entity.PROMOTIONPRICE;
                        updateEntity.INTERNALPRICE        = entity.INTERNALPRICE;
                        updateEntity.SPECIALPRICE         = entity.SPECIALPRICE;
                        updateEntity.ENABLED            = entity.ENABLED;
                        updateEntity.PRODUCTDESCRIPTION = entity.PRODUCTDESCRIPTION;
                    }

                    int value = manager.Update(updateEntity);
                    if (value > 0)
                    {
                        msg         = RDIFrameworkMessage.MSG0010;
                        isSuccess   = true;
                        returnValue = value.ToString();
                    }
                    context.Response.Write(new JsonMessage {
                        Success = isSuccess, Data = returnValue, Message = msg
                    }.ToString());
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(new JsonMessage {
                    Success = false, Data = "0", Message = "操作失败:" + ex.Message
                }.ToString());
            }
        }