private void ShowDefineInfo()
        {
            if (DefineCodeDt == null)
            {
                return;
            }

            if (DefineCodeDt.DefaultView.Count == 0)
            {
                return;
            }

            DataRow dr = this.gVDefineInfo.GetDataRow(this.gVDefineInfo.FocusedRowHandle);

            defineInfoModel = GetDefineInfoModel(dr);

            //显示数据
            if (defineInfoModel != null)
            {
                this.txtViewProductName.Text = defineInfoModel.CommerceName;
                this.txtViewCommName.Text    = defineInfoModel.CommonName;
                this.txtViewSpec.Text        = defineInfoModel.Spec;
                this.txtViewModel.Text       = defineInfoModel.Model;
                this.txtViewManuName.Text    = defineInfoModel.ManuName;
                this.txtViewPrice.Text       = defineInfoModel.Price;
                this.txtProductMnemonic.Text = defineInfoModel.ProductMnemonic;
                this.txtSelfPackage.Text     = defineInfoModel.SelfPackage;
                this.txtAlias.Text           = defineInfoModel.Alias;
                this.txtAliasPinyin.Text     = defineInfoModel.AliasPinyin;
            }
        }
        /// <summary>
        /// 判断自定义编码产品表中该产品是否已添加
        /// </summary>
        /// <param name="productcode"></param>
        /// <returns></returns>
        public bool DefineCodeIsAddProductId(DefineInfoModel model, DbTransaction transaction)
        {
            bool flag = false;

            StringBuilder strSql = new StringBuilder();

            strSql.AppendFormat(@"Select 
                                Count(1) 
                                From hc_self_define_info 
                                Where HIT_COMM_ID='{0}'", model.Hit_Comm_Id);

            try
            {
                int Count = Convert.ToInt16(DbFacade.SQLExecuteScalar(strSql.ToString(), transaction).ToString());
                if (Count > 0)
                {
                    //已添加
                    flag = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(flag);
        }
        //获取当前自定义编码修改对象
        private DefineInfoModel GetDefineInfoModel()
        {
            DefineInfoModel model = new DefineInfoModel();

            model.Hit_Comm_Id     = strHitCommID;
            model.ProductMnemonic = this.txtProductMnemonic.Text.Trim();
            model.SelfPackage     = this.txtSelfPackage.Text.Trim();
            model.Alias           = this.txtAlias.Text.Trim();
            model.AliasPinyin     = this.txtAliasPinyin.Text.Trim();

            return(model);
        }
        /// <summary>
        /// 获取修改后的自定义编码列表对象
        /// </summary>
        /// <returns></returns>
        private List <DefineInfoModel> GetDefineInfoListModel()
        {
            defineInfoListModel.Clear();

            foreach (DataRow dr in DefineCodeDt.Rows)
            {
                if (dr.RowState == DataRowState.Modified)
                {
                    //if (!string.IsNullOrEmpty(dr["SELF_PACKAGE"].ToString()))
                    //{
                    DefineInfoModel model = GetDefineInfoModel(dr);

                    defineInfoListModel.Add(model);
                    //}
                }
            }
            return(defineInfoListModel);
        }
 /// <summary>
 /// 自定义编码及大包装操作
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void OperatorDefineInfo(DefineInfoModel model, LogedInUser logedinUser, DbTransaction transaction)
 {
     try
     {
         //判断该产品ID是否已添加 是则进入修改 否则进入新增方法
         if (!DefineCodeIsAddProductId(model, transaction))
         {
             InsertDefineInfo(model, logedinUser, transaction);
         }
         else
         {
             ModifyDefineInfo(model, logedinUser, transaction);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 获取当前选中行对象
        /// </summary>
        /// <returns></returns>
        private DefineInfoModel GetDefineInfoModel(DataRow dr)
        {
            DefineInfoModel model = new DefineInfoModel();

            model.Hit_Comm_Id     = dr["HIT_COMM_ID"].ToString();
            model.CommerceName    = dr["PRODUCT_NAME"].ToString();
            model.CommonName      = dr["COMMON_NAME"].ToString();
            model.Spec            = dr["SPEC"].ToString();
            model.Model           = dr["MODEL"].ToString();
            model.ManuName        = dr["MANU_NAME"].ToString();
            model.Price           = base.SetNumFormat(dr["PRICE"].ToString());
            model.ProductMnemonic = dr["PRODUCT_MNEMONIC"].ToString();
            model.SelfPackage     = dr["SELF_PACKAGE"].ToString();
            if (string.IsNullOrEmpty(model.SelfPackage))
            {
                model.SelfPackage = "1";
            }
            model.Alias       = dr["ALIAS"].ToString();
            model.AliasPinyin = dr["ALIAS_PINYIN"].ToString();

            return(model);
        }
        /// <summary>
        /// 修改保存操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtProductMnemonic.Text))
            {
                if (DefineCodeBLL.GetInstance().DefineCodeIsAddProductMnemonic(this.txtProductMnemonic.Text, strHitCommID))
                {
                    XtraMessageBox.Show("自定义编码已存在,请重新输入!", Constant.MsgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.txtProductMnemonic.Focus();
                    return;
                }
            }

            if (this.LueSenderName.EditValue == null)
            {
                XtraMessageBox.Show("请选择配送商企业!", Constant.MsgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            OrdHitCommMode ordHitCommmodel = GetOrdHitCommModel();

            List <DefineInfoModel> defineInfoListmodel = new List <DefineInfoModel>();
            DefineInfoModel        defineInfoModel     = GetDefineInfoModel();

            defineInfoListmodel.Add(defineInfoModel);
            try
            {
                StockListBLL.GetInstance().PostOrdHitCommInfo(ordHitCommmodel, CurrentUser);
                DefineCodeBLL.GetInstance().OperatorDefineInfoList(defineInfoListmodel, CurrentUser);
                XtraMessageBox.Show("采购目录信息修改成功!", Constant.MsgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.EditFlag = true;

                this.Close();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("采购目录信息修改失败!", Constant.MsgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// 自定义编码及大包装保存
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public void InsertDefineInfo(DefineInfoModel model, LogedInUser logedinUser, DbTransaction transaction)
        {
            int result = 0;
            //生成本地ID
            string strId    = base.GetClientId(logedinUser.HighId).ToString();
            string strOrgId = logedinUser.UserOrg.Id;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("Insert Into hc_self_define_info");
            strSql.Append(" (");
            strSql.Append("ID, ORGID, HIT_COMM_ID, PRODUCT_MNEMONIC, SELF_PACKAGE, ALIAS, ALIAS_PINYIN, MODIFY_USERID, MODIFY_DATE, SYNC_STATE");
            strSql.Append(")");
            strSql.Append(" Values");

            strSql.Append("(");
            strSql.AppendFormat("'{0}',", strId);
            strSql.AppendFormat("'{0}',", strOrgId);
            strSql.AppendFormat("'{0}',", model.Hit_Comm_Id);
            strSql.AppendFormat("'{0}',", model.ProductMnemonic);
            strSql.AppendFormat("'{0}',", model.SelfPackage);
            strSql.AppendFormat("'{0}',", model.Alias);
            strSql.AppendFormat("'{0}',", model.AliasPinyin);
            strSql.AppendFormat("'{0}',", logedinUser.UserInfo.Id);
            strSql.AppendFormat("'{0}',", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            strSql.Append("'0'");
            strSql.Append(")");

            try
            {
                result = base.DbFacade.SQLExecuteNonQuery(strSql.ToString(), transaction);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 自定义编码及大包装修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public void ModifyDefineInfo(DefineInfoModel model, LogedInUser logedinUser, DbTransaction transaction)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("Update hc_self_define_info ");
            strSql.Append("Set ");
            strSql.Append(" SYNC_STATE='0'");
            strSql.AppendFormat(",PRODUCT_MNEMONIC='{0}'", model.ProductMnemonic);
            strSql.AppendFormat(",SELF_PACKAGE='{0}'", model.SelfPackage);
            strSql.AppendFormat(",ALIAS='{0}'", model.Alias);
            strSql.AppendFormat(",ALIAS_PINYIN='{0}'", model.AliasPinyin);
            strSql.AppendFormat(",MODIFY_USERID='{0}'", logedinUser.UserInfo.Id);
            strSql.AppendFormat(",MODIFY_DATE='{0}'", DateTime.Now.ToShortDateString());
            strSql.AppendFormat(" Where HIT_COMM_ID='{0}'", model.Hit_Comm_Id);

            try
            {
                base.DbFacade.SQLExecuteNonQuery(strSql.ToString(), transaction);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }