public string Save() { System.Data.SqlClient.SqlCommand cmd = null; DBConn Obj = new DBConn(); try { cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO FormTable VALUES (@F8,@F9);select SCOPE_IDENTITY();", Obj.Con); cmd.Parameters.AddWithValue("@F8", this.F8); cmd.Parameters.AddWithValue("@F9", this.F9); this.F8 = cmd.ExecuteScalar().ToString(); } catch (System.Exception e) { this.F8 = null; e.ToString(); } finally { cmd.Dispose(); Obj.ConClose(Obj.Con); } return(this.F8); }
public int Save() { System.Data.SqlClient.SqlCommand cmd = null; DBConn Obj = new DBConn(); try { if (this.TableFieldId == 0) { cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO FormTableProperty VALUES (@FormTableId,@FormFieldName,@FieldType,@FieldValue,@DefaultValue,@FormFieldOrder,@FieldColSpan,@Class,@Format,@JavaScript,@CheckRights,@DisplayInDataTable);select SCOPE_IDENTITY();", Obj.Con); } else { cmd = new System.Data.SqlClient.SqlCommand("UPDATE FormTableProperty SET FormTableId=@FormTableId,FormFieldName=@FormFieldName,FieldType=@FieldType,FieldValue=@FieldValue,DefaultValue=@DefaultValue,FormFieldOrder=@FormFieldOrder,FieldColSpan=@FieldColSpan,Class=@Class,Format=@Format,JavaScript=@JavaScript,CheckRights=@CheckRights,DisplayInDataTable=@DisplayInDataTable where TableFieldId=@TableFieldId", Obj.Con); cmd.Parameters.AddWithValue("@TableFieldId", this.TableFieldId); } cmd.Parameters.AddWithValue("@FormTableId", this.FormTableId); cmd.Parameters.AddWithValue("@FormFieldName", this.FieldName); cmd.Parameters.AddWithValue("@FieldType", this.FieldType); cmd.Parameters.AddWithValue("@FormFieldOrder", this.FormFieldOrder); cmd.Parameters.AddWithValue("@FieldColSpan", this.FieldColSpan); cmd.Parameters.AddWithValue("@DisplayInDataTable", this.DisplayInDataTable); if (string.IsNullOrEmpty(this.FieldValue)) { cmd.Parameters.AddWithValue("@FieldValue", DBNull.Value); } else { cmd.Parameters.AddWithValue("@FieldValue", this.FieldValue); } if (string.IsNullOrEmpty(this.DefualValue)) { cmd.Parameters.AddWithValue("@DefaultValue", DBNull.Value); } else { cmd.Parameters.AddWithValue("@DefaultValue", this.DefualValue); } if (string.IsNullOrEmpty(this.FiledClass)) { cmd.Parameters.AddWithValue("@Class", DBNull.Value); } else { cmd.Parameters.AddWithValue("@Class", this.FiledClass); } if (string.IsNullOrEmpty(this.Format)) { cmd.Parameters.AddWithValue("@Format", DBNull.Value); } else { cmd.Parameters.AddWithValue("@Format", this.Format); } if (string.IsNullOrEmpty(this.JavaScript)) { cmd.Parameters.AddWithValue("@JavaScript", DBNull.Value); } else { cmd.Parameters.AddWithValue("@JavaScript", this.JavaScript); } if (string.IsNullOrEmpty(this.CheckRights)) { cmd.Parameters.AddWithValue("@CheckRights", DBNull.Value); } else { cmd.Parameters.AddWithValue("@CheckRights", this.CheckRights); } if (this.TableFieldId == 0) { this.TableFieldId = int.Parse(cmd.ExecuteScalar().ToString()); } else { if (cmd.ExecuteNonQuery() <= 0) { this.TableFieldId = 0; } } } catch (System.Exception e) { this.TableFieldId = 0; e.ToString(); } finally { cmd.Dispose(); Obj.ConClose(Obj.Con); } return(this.TableFieldId); }