Esempio n. 1
0
 private void txtCode_Leave(object sender, EventArgs e)
 {
     //判断编号是否已存在
     if (!string.IsNullOrEmpty(this.txtCode.Text.Trim()))
     {
         BaseLocationTable LocationCode = new BaseLocationTable();
         LocationCode = bLocation.GetModel(txtCode.Text, txtProductCode.Text, txtWarehouseCode.Text);
         if (LocationCode != null)
         {
             txtCode.Focus();
             txtCode.Text = "";
             MessageBox.Show("编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BaseLocationTable GetModel(string CODE, string PRODUCT_CODE, string WAREHOUSE_CODE)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CODE,WAREHOUSE_CODE,PRODUCT_CODE,NAME,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_USER,LAST_UPDATE_TIME from BASE_LOCATION ");
            strSql.Append(" where CODE=@CODE AND PRODUCT_CODE=@PRODUCT_CODE AND WAREHOUSE_CODE=@WAREHOUSE_CODE ");
            strSql.AppendFormat(" and STATUS_FLAG <> {0}", CConstant.DELETE_STATUS);
            SqlParameter[] parameters =
            {
                new SqlParameter("@CODE",           SqlDbType.VarChar, 50),
                new SqlParameter("@PRODUCT_CODE",   SqlDbType.VarChar, 50),
                new SqlParameter("@WAREHOUSE_CODE", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = CODE;
            parameters[1].Value = PRODUCT_CODE;
            parameters[2].Value = WAREHOUSE_CODE;
            BaseLocationTable model = new BaseLocationTable();
            DataSet           ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.CODE           = ds.Tables[0].Rows[0]["CODE"].ToString();
                model.PRODUCT_CODE   = ds.Tables[0].Rows[0]["PRODUCT_CODE"].ToString();
                model.WAREHOUSE_CODE = ds.Tables[0].Rows[0]["WAREHOUSE_CODE"].ToString();
                model.NAME           = ds.Tables[0].Rows[0]["NAME"].ToString();
                if (ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString() != "")
                {
                    model.STATUS_FLAG = int.Parse(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString());
                }
                model.CREATE_USER = ds.Tables[0].Rows[0]["CREATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString() != "")
                {
                    model.CREATE_DATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString());
                }
                model.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString() != "")
                {
                    model.LAST_UPDATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获得当前选中的数据
        /// </summary>
        private void GetCurrentSelectedTable()
        {
            try
            {
                string code           = dgvData.SelectedRows[0].Cells["CODE"].Value.ToString();
                string product_code   = dgvData.SelectedRows[0].Cells["PRODUCT_CODE"].Value.ToString();
                string warehouse_code = dgvData.SelectedRows[0].Cells["WAREHOUSE_CODE"].Value.ToString();
                if (code != "")
                {
                    _currentLocationTable = bLocation.GetModel(code, product_code, warehouse_code);
                }
            }
            catch (Exception ex) { }

            if (_currentLocationTable == null || _currentLocationTable.CODE == null || "".Equals(_currentLocationTable.CODE))
            {
                _currentLocationTable = null;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 打开新窗口
        /// </summary>
        private void OpenDialogFrm(int mode)
        {
            if (mode == CConstant.MODE_NEW || _currentLocationTable != null)
            {
                FrmLocationDialog frm = new FrmLocationDialog();
                frm.UserInfo             = _userInfo;
                frm.CurrentLocationTable = _currentLocationTable;
                frm.Mode = mode;
                DialogResult resule = frm.ShowDialog(this);
                if (resule == DialogResult.OK && isSearch)
                {
                    Search(this.pgControl.GetCurrentPage());
                }
                frm.Dispose();
            }
            else
            {
                //MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            _currentLocationTable = null;
        }
Esempio n. 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BaseLocationTable model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BASE_LOCATION set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("STATUS_FLAG=@STATUS_FLAG,");
            strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,");
            strSql.Append("LAST_UPDATE_TIME=GETDATE()");
            strSql.Append(" where CODE=@CODE AND PRODUCT_CODE=@PRODUCT_CODE AND WAREHOUSE_CODE=@WAREHOUSE_CODE ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CODE",             SqlDbType.VarChar,   20),
                new SqlParameter("@PRODUCT_CODE",     SqlDbType.VarChar,   40),
                new SqlParameter("@WAREHOUSE_CODE",   SqlDbType.VarChar,   20),
                new SqlParameter("@NAME",             SqlDbType.NVarChar, 100),
                new SqlParameter("@STATUS_FLAG",      SqlDbType.Int,        4),
                new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.CODE;
            parameters[1].Value = model.PRODUCT_CODE;
            parameters[2].Value = model.WAREHOUSE_CODE;
            parameters[3].Value = model.NAME;
            parameters[4].Value = model.STATUS_FLAG;
            parameters[5].Value = model.LAST_UPDATE_USER;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (_currentLocationTable == null)
                {
                    _currentLocationTable = new BaseLocationTable();
                }

                _currentLocationTable.CODE             = txtCode.Text;
                _currentLocationTable.NAME             = txtName.Text;
                _currentLocationTable.PRODUCT_CODE     = txtProductCode.Text;
                _currentLocationTable.WAREHOUSE_CODE   = txtWarehouseCode.Text;
                _currentLocationTable.LAST_UPDATE_USER = _userInfo.CODE;

                try
                {
                    if (bLocation.Exists(txtCode.Text.Trim(), txtProductCode.Text.Trim(), txtWarehouseCode.Text.Trim()))
                    {
                        bLocation.Update(_currentLocationTable);
                    }
                    else
                    {
                        _currentLocationTable.CREATE_USER = _userInfo.CODE;
                        bLocation.Add(_currentLocationTable);
                    }
                }
                catch (Exception ex)
                {
                    //log.error
                    MessageBox.Show("");
                    return;
                }
                result = DialogResult.OK;
                this.Close();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// 删除
 /// </summary>
 private void MasterToolBar_DoDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK)
     {
         try
         {
             GetCurrentSelectedTable();
             if (_currentLocationTable != null)
             {
                 bLocation.Delete(_currentLocationTable.CODE, _currentLocationTable.PRODUCT_CODE, _currentLocationTable.WAREHOUSE_CODE);
                 Search(this.pgControl.GetCurrentPage());
             }
             else
             {
                 MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         _currentLocationTable = null;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(BaseLocationTable model)
        {
            StringBuilder strSql = null;
            int           rows   = 0;

            if (Exists(model.CODE, model.PRODUCT_CODE, model.WAREHOUSE_CODE))
            {
                #region 更新
                strSql = new StringBuilder();
                strSql.Append("update BASE_LOCATION set ");
                strSql.Append("NAME=@NAME,");
                strSql.Append("STATUS_FLAG=@STATUS_FLAG,");
                strSql.Append("CREATE_USER=@CREATE_USER,");
                strSql.Append("CREATE_DATE_TIME=GETDATE(),");
                strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,");
                strSql.Append("LAST_UPDATE_TIME=GETDATE()");
                strSql.Append(" where CODE=@CODE AND PRODUCT_CODE=@PRODUCT_CODE AND WAREHOUSE_CODE=@WAREHOUSE_CODE");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CODE",             SqlDbType.VarChar,   20),
                    new SqlParameter("@PRODUCT_CODE",     SqlDbType.VarChar,   40),
                    new SqlParameter("@WAREHOUSE_CODE",   SqlDbType.VarChar,   20),
                    new SqlParameter("@NAME",             SqlDbType.NVarChar, 100),
                    new SqlParameter("@STATUS_FLAG",      SqlDbType.Int,        4),
                    new SqlParameter("@CREATE_USER",      SqlDbType.VarChar,   20),
                    new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20)
                };
                parameters[0].Value = model.CODE;
                parameters[1].Value = model.PRODUCT_CODE;
                parameters[2].Value = model.WAREHOUSE_CODE;
                parameters[3].Value = model.NAME;
                parameters[4].Value = CConstant.NORMAL_STATUS;
                parameters[5].Value = model.CREATE_USER;
                parameters[6].Value = model.LAST_UPDATE_USER;
                rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                #endregion
            }
            else
            {
                #region 增加
                strSql = new StringBuilder();
                strSql.Append("insert into BASE_LOCATION(");
                strSql.Append("CODE,PRODUCT_CODE,WAREHOUSE_CODE,NAME,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_USER,LAST_UPDATE_TIME)");
                strSql.Append(" values (");
                strSql.Append("@CODE,@PRODUCT_CODE,@WAREHOUSE_CODE,@NAME,@STATUS_FLAG,@CREATE_USER,GETDATE(),@LAST_UPDATE_USER,GETDATE())");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CODE",             SqlDbType.VarChar,   20),
                    new SqlParameter("@PRODUCT_CODE",     SqlDbType.VarChar,   40),
                    new SqlParameter("@WAREHOUSE_CODE",   SqlDbType.VarChar,   20),
                    new SqlParameter("@NAME",             SqlDbType.NVarChar, 100),
                    new SqlParameter("@STATUS_FLAG",      SqlDbType.Int,        4),
                    new SqlParameter("@CREATE_USER",      SqlDbType.VarChar,   20),
                    new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20)
                };
                parameters[0].Value = model.CODE;
                parameters[1].Value = model.PRODUCT_CODE;
                parameters[2].Value = model.WAREHOUSE_CODE;
                parameters[3].Value = model.NAME;
                parameters[4].Value = CConstant.NORMAL_STATUS;
                parameters[5].Value = model.CREATE_USER;
                parameters[6].Value = model.LAST_UPDATE_USER;
                rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                #endregion
            }
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 9
0
        public override string[] doUpdateDB()
        {
            BaseLocationTable LocationTable = null;
            BLocation         bLocation     = new BLocation();
            StringBuilder     strError      = new StringBuilder();
            int    successData    = 0;
            int    failureData    = 0;
            string errorFilePath  = "";
            string backupFilePath = "";

            //数据导入处理
            foreach (DataRow dr in _csvDataTable.Rows)
            {
                StringBuilder str = new StringBuilder();
                //编号
                if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE"))))
                {
                    str.Append(CheckString(GetValue(dr, "CODE"), 20, "编号"));
                }
                else
                {
                    str.Append("编号不能为空!");
                }
                //名称
                str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称"));
                //状态
                str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 9, "状态"));

                if (str.ToString().Trim().Length > 0)
                {
                    strError.Append(GetStringBuilder(dr, str.ToString().Trim()));
                    failureData++;
                    continue;
                }
                try
                {
                    LocationTable                  = new BaseLocationTable();
                    LocationTable.CODE             = CConvert.ToString(GetValue(dr, "CODE"));
                    LocationTable.NAME             = CConvert.ToString(GetValue(dr, "NAME"));
                    LocationTable.STATUS_FLAG      = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS));
                    LocationTable.CREATE_USER      = _userInfo.CODE;
                    LocationTable.LAST_UPDATE_USER = _userInfo.CODE;

                    if (!bLocation.Exists(LocationTable.CODE))
                    {
                        LocationTable.CREATE_DATE_TIME = DateTime.Now;
                        LocationTable.LAST_UPDATE_TIME = DateTime.Now;
                        bLocation.Add(LocationTable);
                    }
                    else
                    {
                        LocationTable.LAST_UPDATE_TIME = DateTime.Now;
                        bLocation.Update(LocationTable);
                    }
                    successData++;
                }
                catch
                {
                    strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString());
                    failureData++;
                }
            }
            //错误记录处理
            if (strError.Length > 0)
            {
                errorFilePath = WriteFile(strError.ToString());
            }

            //备份处理
            backupFilePath = BackupFile();

            return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath });
        }
Esempio n. 10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BaseLocationTable model)
 {
     return(dal.Update(model));
 }
Esempio n. 11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(BaseLocationTable model)
 {
     return(dal.Add(model));
 }