예제 #1
0
        /// <summary>
        /// 验证品名规格型号合法性
        /// </summary>
        /// <param name="dgv"></param>
        /// <param name="cell"></param>
        /// <returns></returns>
        private bool validate品名规格型号(myDataGridView dgv, DataGridViewCell cell)
        {
            if (dgv.Rows[cell.RowIndex].Cells["手册id"].Value == DBNull.Value || Convert.ToInt32(dgv.Rows[cell.RowIndex].Cells["手册id"].Value) <= 0)
            {
                SysMessage.InformationMsg("请先选择手册编号!");
                return(false);
            }
            string strSQL = string.Empty;

            strSQL = string.Format("SELECT 进口料件id, 商品编号, 品名规格型号, 单位 FROM 进口料件表 where 手册id={0} and 品名规格型号 like '%{1}%'",
                                   dgv.Rows[cell.RowIndex].Cells["手册id"].Value, StringTools.SqlLikeQ(cell.EditedFormattedValue.ToString()));

            IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Uniquegrade);

            dataAccess.Open();
            DataTable dtData = dataAccess.GetTable(strSQL, null);

            dataAccess.Close();
            if (dtData.Rows.Count == 1)
            {
                DataRow row = dtData.Rows[0];
                dgv.Rows[cell.RowIndex].Cells["进口料件id"].Value = row["进口料件id"];
                dgv.Rows[cell.RowIndex].Cells["商品编号"].Value   = row["商品编号"];
                dgv.Rows[cell.RowIndex].Cells["单位"].Value     = row["单位"];
                dgv.Rows[cell.RowIndex].Cells["品名规格型号"].Value = row["品名规格型号"];
            }
            else if (dtData.Rows.Count > 1)
            {
                FormBaseSingleSelect formSelect = new FormBaseSingleSelect();
                formSelect.strFormText = "选择资料";
                formSelect.dtData      = dtData;
                if (formSelect.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    dgv.Rows[cell.RowIndex].Cells["进口料件id"].Value = formSelect.returnRow["进口料件id"];
                    dgv.Rows[cell.RowIndex].Cells["商品编号"].Value   = formSelect.returnRow["商品编号"];
                    dgv.Rows[cell.RowIndex].Cells["单位"].Value     = formSelect.returnRow["单位"];
                    dgv.Rows[cell.RowIndex].Cells["品名规格型号"].Value = formSelect.returnRow["品名规格型号"];
                }
                else
                {
                    dgv.CurrentCell = cell;
                    return(false);
                }
            }
            else
            {
                SysMessage.InformationMsg("此商品编号不存在!");
                dgv.CurrentCell = cell;
                return(false);
            }
            return(true);
        }
예제 #2
0
        /// <summary>
        /// 验证手册编号合法性
        /// </summary>
        /// <param name="dgv"></param>
        /// <param name="cell"></param>
        /// <returns></returns>
        private bool validate手册编号(myDataGridView dgv, DataGridViewCell cell)
        {
            string strSQL = string.Empty;

            strSQL = string.Format("SELECT 手册id, 手册编号, 有效期限, 进出口岸一 FROM 手册资料表 where 手册编号 like '%{0}%'", StringTools.SqlLikeQ(cell.EditedFormattedValue.ToString()));
            IDataAccess dataAccess = DataAccessFactory.CreateDataAccess(DataAccessEnum.DataAccessName.DataAccessName_Uniquegrade);

            dataAccess.Open();
            DataTable dtData = dataAccess.GetTable(strSQL, null);

            dataAccess.Close();
            if (dtData.Rows.Count == 1)
            {
                DataRow row = dtData.Rows[0];
                dgv.Rows[cell.RowIndex].Cells["手册id"].Value = row["手册id"];
                dgv.Rows[cell.RowIndex].Cells["手册编号"].Value = row["手册编号"];
            }
            else if (dtData.Rows.Count > 1)
            {
                FormBaseSingleSelect formSelect = new FormBaseSingleSelect();
                formSelect.strFormText = "选择资料";
                formSelect.dtData      = dtData;
                if (formSelect.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    dgv.Rows[cell.RowIndex].Cells["手册id"].Value = formSelect.returnRow["手册id"];
                    dgv.Rows[cell.RowIndex].Cells["手册编号"].Value = formSelect.returnRow["手册编号"];
                }
                else
                {
                    dgv.CurrentCell = cell;
                    return(false);
                }
            }
            else
            {
                SysMessage.InformationMsg("此手册编号不存在!");
                dgv.CurrentCell = cell;
                return(false);
            }
            return(true);
        }