Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataGridView"></param>
        /// <param name="strValue"></param>
        /// <param name="_columnIndex"></param>
        /// <param name="_rowIndex"></param>
        public void CPaste(DataGridView dataGridView, string strValue, int _columnIndex, int _rowIndex)
        {
            if (strValue == string.Empty)
            {
                return;
            }

            if (_columnIndex < 0 || _columnIndex >= dataGridView.Columns.Count)
            {
                return;
            }

            if (_rowIndex < 0 || _rowIndex >= dataGridView.Rows.Count)
            {
                return;
            }

            OilDataSearchEntity searchData = null;
            int oilTableColID = 0, oilTableRowID = 0;

            string colTag = dataGridView.Columns[_columnIndex].Tag == null ? string.Empty : dataGridView.Columns[_columnIndex].Tag.ToString();
            string rowTag = dataGridView.Rows[_rowIndex].Tag == null ? string.Empty : dataGridView.Rows[_rowIndex].Tag.ToString();

            if (colTag != string.Empty && rowTag != string.Empty)
            {
                if (int.TryParse(dataGridView.Columns[_columnIndex].Tag.ToString(), out oilTableColID) && int.TryParse(dataGridView.Rows[_rowIndex].Tag.ToString(), out oilTableRowID))
                {
                    searchData               = new OilDataSearchEntity();
                    searchData.calData       = strValue;
                    searchData.oilInfoID     = this._COilID;
                    searchData.oilTableColID = oilTableColID;
                    searchData.oilTableRowID = oilTableRowID;

                    OilDataSearchAccess dataSearch = new OilDataSearchAccess();
                    OilDataSearchEntity temp       = dataSearch.Get("oilInfoID = " + this._COilID + "and  oilTableColID = " + oilTableColID + "and  oilTableRowID = " + oilTableRowID).FirstOrDefault();
                    if (temp == null)
                    {
                        dataSearch.Insert(searchData);
                    }
                    else
                    {
                        dataSearch.Update(searchData, temp.ID.ToString());
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="dataGridView"></param>
        public void CSave(DataGridView dataGridView)
        {
            dataGridView.EndEdit();
            for (int colIndex = 3; colIndex < dataGridView.Columns.Count; colIndex++)
            {
                for (int rowIndex = 0; rowIndex < dataGridView.Rows.Count; rowIndex++)
                {
                    OilDataSearchEntity searchData = null;
                    int oilTableColID = 0, oilTableRowID = 0;

                    string colTag = dataGridView.Columns[colIndex].Tag == null ? string.Empty : dataGridView.Columns[colIndex].Tag.ToString();
                    string rowTag = dataGridView.Rows[rowIndex].Tag == null ? string.Empty : dataGridView.Rows[rowIndex].Tag.ToString();
                    string strValue = dataGridView.Rows[rowIndex].Cells[colIndex].Value == null ? string.Empty : dataGridView.Rows[rowIndex].Cells[colIndex].Value.ToString();
                    if (colTag != string.Empty && rowTag != string.Empty)
                    {
                        if (int.TryParse(colTag, out oilTableColID) && int.TryParse(rowTag, out oilTableRowID))
                        {
                            OilDataSearchAccess dataSearch = new OilDataSearchAccess();
                            OilDataSearchEntity temp       = dataSearch.Get("oilInfoID = " + this._COilID + "and  oilTableColID = " + oilTableColID + "and  oilTableRowID = " + oilTableRowID).FirstOrDefault();
                            if (temp == null)
                            {
                                searchData               = new OilDataSearchEntity();
                                searchData.calData       = strValue;
                                searchData.oilInfoID     = this._COilID;
                                searchData.oilTableColID = oilTableColID;
                                searchData.oilTableRowID = oilTableRowID;
                                dataSearch.Insert(searchData);
                            }
                            else if (temp.calData != strValue)
                            {
                                searchData               = new OilDataSearchEntity();
                                searchData.calData       = strValue;
                                searchData.oilInfoID     = this._COilID;
                                searchData.oilTableColID = oilTableColID;
                                searchData.oilTableRowID = oilTableRowID;
                                dataSearch.Update(searchData, temp.ID.ToString());
                            }
                        }
                    }
                }
            }
        }