string createDeleteStatementForGrid(HGrid grd) { string sql = ""; string fieldName = ""; string fieldValue = ""; string critria = ""; if (frm.recordMode == DataForm.RecordMode.Delete && grd.TableName != null) { sql = "Delete From " + grd.TableName + ""; // Mohamed samir 22/5/2013 string Exist = "0"; Exist = DataLayer.Executescalar(@"SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '" + grd.TableName + "' and column_name = 'BranchCode'"); if (Exist == "1") { if (frm.recordMode == DataForm.RecordMode.Delete) { critria += " and BranchCode = " + GlobalVariables.BranchCode; } } // Mohamed samir 22/5/2013 foreach (Control co in frm.Controls) { #region textbox if (co is HTextBox) { HTextBox ht = co as HTextBox; if (ht.FieldName != "" && ht.Text != "") { if (frm.recordMode == DataForm.RecordMode.Insert) { if (ht._DataType == DataType.Integer || ht._DataType == DataType.Decimal) { fieldName += ht.FieldName + ","; fieldValue += ht.Text + ","; } else if (ht._DataType == DataType.String || ht._DataType == DataType.DateTime) { fieldName += ht.FieldName + ","; fieldValue += "'" + ht.Text + "',"; } } else if (frm.recordMode == DataForm.RecordMode.Update) { if (ht.key == true) { critria += " and " + ht.FieldName + " = " + ht.Text; } else { if (ht._DataType == DataType.Integer || ht._DataType == DataType.Decimal) { fieldValue += ht.FieldName + "=" + ht.Text + ","; } else if (ht._DataType == DataType.String || ht._DataType == DataType.DateTime) { fieldValue += ht.FieldName + "='" + ht.Text + "',"; } } } else if (frm.recordMode == DataForm.RecordMode.Delete) { if (frm.recordMode == DataForm.RecordMode.Delete) { if (ht.key == true) critria += " and " + ht.FieldName + " = " + ht.Text; } } } } #endregion #region checkBox else if (co is HCheckbox) { HCheckbox ht = co as HCheckbox; if (ht.FieldName != "") { if (frm.recordMode == DataForm.RecordMode.Insert) { fieldName += ht.FieldName + ","; fieldValue += (ht.Checked == true ? "1" : "0") + ","; } else if (frm.recordMode == DataForm.RecordMode.Update) { fieldValue += ht.FieldName + "=" + (ht.Checked == true ? "1" : "0") + ","; } } } #endregion } #region Compelete Statement if (frm.recordMode == DataForm.RecordMode.Insert) { if (fieldName != "") { fieldName = fieldName.Remove(fieldName.Length - 1); fieldName += ")"; } if (fieldValue != "") { fieldValue = fieldValue.Remove(fieldValue.Length - 1); fieldValue += ")"; } sql += fieldName + fieldValue; } else if (frm.recordMode == DataForm.RecordMode.Update) { fieldValue = fieldValue.Remove(fieldValue.Length - 1); sql += fieldName + fieldValue + " where 1=1 " + critria; } else if (frm.recordMode == DataForm.RecordMode.Delete) { if (critria != "") sql += " where 1=1 " + critria; } #endregion return sql; } else return sql; }
bool isEmptyRow(HGrid grd, int RowIndex) { if (grd.Rows[RowIndex].Cells[0].Value == null) { return true; } return false; }
public ColumnSelector(HGrid dgv) : this() { this.Grid = dgv; }
public RowEvents(HGrid dgv) : this() { this.Grid = dgv; }