Пример #1
0
        private bool Save()
        {
            if (!IsFieldValueValid())
            {
                return(false);
            }

            try
            {
                RecLocationEntity entity = PrepareSave();
                bool isCreateNew         = (this.recLocationEntity == null);
                //int result = recLocationDal.Save(entity, isCreateNew);
                //if (result == -1)
                //{
                //    MsgBox.Warn("编号已经存在,请改为其他的编号。");
                //    return false;
                //}
                if (SaveUpdate(entity, isCreateNew))
                {
                    if (DataSourceChanged != null)
                    {
                        DataSourceChanged(null, null);
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
                return(false);
            }

            return(false);
        }
Пример #2
0
        public int Save(RecLocationEntity entity, bool IsCreateNew)
        {
            IMapper map = DatabaseInstance.Instance();
            int     ret = -1;

            if (entity.RecLoc == "")
            {
                ret = map.Execute("Insert into wm_sku_location (LC_CODE,SKU_CODE) values(@lcCode,@skuCode)",
                                  new
                {
                    lcCode  = entity.Location,
                    skuCode = entity.SkuCode
                });
            }
            else
            {
                ret = map.Execute("Update wm_sku_location set  SKU_CODE=@skuCode where LC_CODE=@lcCode",
                                  new
                {
                    skuCode = entity.SkuCode,
                    lcCode  = entity.Location
                });
            }
            return(ret);
        }
Пример #3
0
        /// <summary>
        /// 基础管理(推荐货位-查询所有推荐货位)
        /// </summary>
        /// <returns></returns>
        public List <RecLocationEntity> GetAllRecLocation()
        {
            List <RecLocationEntity> list = new List <RecLocationEntity>();

            try
            {
                #region 请求数据
                System.Text.StringBuilder loStr = new System.Text.StringBuilder();
                //loStr.Append("roleId=").Append(roleId);
                string jsonQuery = WebWork.SendRequest(string.Empty, WebWork.URL_GetAllRecLocation);
                if (string.IsNullOrEmpty(jsonQuery))
                {
                    MsgBox.Warn(WebWork.RESULT_NULL);
                    //LogHelper.InfoLog(WebWork.RESULT_NULL);
                    return(list);
                }
                #endregion

                #region 正常错误处理

                JsonGetAllRecLocation bill = JsonConvert.DeserializeObject <JsonGetAllRecLocation>(jsonQuery);
                if (bill == null)
                {
                    MsgBox.Warn(WebWork.JSON_DATA_NULL);
                    return(list);
                }
                if (bill.flag != 0)
                {
                    MsgBox.Warn(bill.error);
                    return(list);
                }
                #endregion

                #region 赋值数据
                foreach (JsonGetAllRecLocationResult jbr in bill.result)
                {
                    RecLocationEntity asnEntity = new RecLocationEntity();
                    asnEntity.Location = jbr.lcCode;
                    asnEntity.RecLoc   = jbr.recLoc;
                    asnEntity.SkuCode  = jbr.skuCode;
                    asnEntity.SkuName  = jbr.skuName;
                    asnEntity.Spec     = jbr.spec;
                    asnEntity.ZnName   = jbr.znName;
                    list.Add(asnEntity);
                }
                return(list);

                #endregion
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
            }
            return(list);
        }
Пример #4
0
        private void ShowEditLocation()
        {
            RecLocationEntity editEntity = SelectedLocationRow;

            if (editEntity == null)
            {
                MsgBox.Warn("没有要修改的数据。");
                return;
            }

            FrmRecLocationEdit frmRecLocationEdit = new FrmRecLocationEdit(editEntity);

            frmRecLocationEdit.DataSourceChanged += OnEditChanage;
            frmRecLocationEdit.ShowDialog();
        }
Пример #5
0
        /// <summary>
        /// 基础管理(推荐货位-添加或编辑库存货位)
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="IsCreateNew"></param>
        /// <returns></returns>
        public bool SaveUpdate(RecLocationEntity entity, bool IsCreateNew)
        {
            try
            {
                #region 请求数据
                System.Text.StringBuilder loStr = new System.Text.StringBuilder();
                loStr.Append("lcCode=").Append(entity.Location).Append("&");
                loStr.Append("skuCode=").Append(entity.SkuCode).Append("&");
                loStr.Append("recLoc=").Append(entity.RecLoc);
                string jsonQuery = WebWork.SendRequest(loStr.ToString(), WebWork.URL_Save);
                if (string.IsNullOrEmpty(jsonQuery))
                {
                    MsgBox.Warn(WebWork.RESULT_NULL);
                    //LogHelper.InfoLog(WebWork.RESULT_NULL);
                    return(false);
                }
                #endregion

                #region 正常错误处理

                Sucess bill = JsonConvert.DeserializeObject <Sucess>(jsonQuery);
                if (bill == null)
                {
                    MsgBox.Warn(WebWork.JSON_DATA_NULL);
                    return(false);
                }
                if (bill.flag != 0)
                {
                    MsgBox.Warn(bill.error);
                    return(false);
                }
                #endregion

                return(true);
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
            }

            return(false);
        }
Пример #6
0
        public void Delete()
        {
            RecLocationEntity removeEntity = SelectedLocationRow;

            if (removeEntity == null)
            {
                MsgBox.Warn("没有要清空的数据。");
                return;
            }
            if (MsgBox.AskOK(string.Format("确定要清空货位\" {0} \"的推荐商品\" {1} \"吗?", removeEntity.RecLoc, removeEntity.SkuName)) == DialogResult.OK)
            {
                bool ret = DeleteRecLoc(removeEntity.RecLoc);
                if (ret)
                {
                    removeEntity.SkuName = "";
                    removeEntity.SkuCode = "";
                    removeEntity.Spec    = "";
                    bindingSource1.ResetBindings(false);
                }
            }
        }
Пример #7
0
        public RecLocationEntity PrepareSave()
        {
            RecLocationEntity editEntity = this.recLocationEntity;

            if (editEntity == null)
            {
                editEntity = new RecLocationEntity();
            }

            MaterialEntity entity = listSku.Properties.View.GetFocusedRow() as MaterialEntity;

            if (entity == null)
            {
                return(null);
            }
            editEntity.SkuCode = entity.MaterialCode;
            editEntity.SkuName = entity.MaterialName;
            editEntity.Spec    = entity.Spec;

            return(editEntity);
        }
Пример #8
0
 public FrmRecLocationEdit(RecLocationEntity entity)
     : this()
 {
     this.recLocationEntity = entity;
 }
Пример #9
0
 private void ShowEditInfo(RecLocationEntity entity)
 {
     //txtCode.Text = grpEntity.GrpCode;
     listSku.EditValue = entity.SkuCode;
     txtlocCode.Text   = entity.Location;
 }