public Boolean cargarGrilla(string nropagina, string campoordenamiento, string id, string idversion, out string sError) { sError = ""; Boolean res; DataTable dt = null; UsersAD usersAd = new UsersAD(); string codError = ""; SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Consultar("USP_SEL_DETALLE_COTIZACIONES_02", out dt, out codError, out sError, nropagina, campoordenamiento, id, idversion); if (!res) { return(false); } /*foreach (DataRow dr in dt.Rows) * { * dr[3] = usersAd.getUserFullName(dr.ItemArray.GetValue(3).ToString()); * }*/ this.dtGrilla = dt; return(true); }
public Boolean AgregarServicioActividadCotizacion(List <iActividad> updCostoJson, string idcotizacion, string idservicio, string cantidad, out string sError) { sError = ""; Boolean res; string xmlVar2 = ""; var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }); var serializer = new XmlSerializer(updCostoJson.GetType()); var settings = new XmlWriterSettings(); settings.Indent = false; settings.OmitXmlDeclaration = true; string xmlVar = ""; using (var stream = new System.IO.StringWriter()) using (var writer = XmlWriter.Create(stream, settings)) { serializer.Serialize(writer, updCostoJson, emptyNamepsaces); xmlVar = stream.ToString(); } SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Ejecutar("USP_INS_SERVICIO_02", out sError, xmlVar, idcotizacion, idservicio, cantidad, GetUserName()); if (!res) { return(false); } return(true); }
public System.Data.DataTable GetList() { SqlAccess access = new SqlAccess(); DataTable dt = access.ExecuteStore("sp_ChinhanhGetAll"); return(dt); }
/*加载系统setting配置,每页10条*/ private void Settings_Load(object sender, EventArgs e) { string sSql = "SELECT Settings.SettingsID, Settings.SettingsName,Settings.SettingsSelect, COUNT(DISTINCT Reader.ReaderID) as ReadNum, COUNT(Antenna.AntennaID) as AntennaNum, Store.StoreName " + "from Settings " + "LEFT JOIN Reader ON Reader.SettingsID = Settings.SettingsID " + "LEFT JOIN Antenna ON Antenna.ReaderID = Reader.ReaderID " + "LEFT JOIN Store ON Store.StoreID = Settings.StoreID " + "GROUP BY Settings.SettingsID,Settings.SettingsName,Settings.SettingsSelect,Store.StoreName " + "order by SettingsID ; "; #if false //modify at 20171202 SqlConnection conn = DbConn.sqlConn(); #else SqlConnection conn = SqlAccess.Connection(); #endif try { //conn.Open(); delete at 20171202 SqlCommand sqlCmd = new SqlCommand(sSql.ToString(), conn); SqlDataAdapter sda = new SqlDataAdapter(sqlCmd); DataSet ds = new DataSet(); sda.Fill(ds, "Settings"); //dataGridViewSettings.DataSource = ds.Tables["Settings"].DefaultView; dataGridViewSettings.DataSource = ds.Tables["Settings"]; conn.Close(); } catch (SqlException ex) { Log.WriteLog(LogType.Error, (ex.Message)); } }
public WineCategoryDetailModel GetDataByID(string id) { StringBuilder sql = new StringBuilder(); sql.AppendLine("SELECT "); sql.AppendLine(" WineCategoryID, WineCategoryName, ImageUrl, IsDelete"); sql.AppendLine(" FROM WineCategory WITH(NOLOCK)"); sql.AppendLine(" WHERE WineCategoryID=@WineCategoryID"); SqlParameter[] paras = new SqlParameter[1]; paras[0] = new SqlParameter("@WineCategoryID", id); SqlAccess mySqlAccess = new SqlAccess(); DataSet ds = mySqlAccess.ExecuteAdapter(sql.ToString(), paras); WineCategoryDetailModel wineCategory = new WineCategoryDetailModel(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; wineCategory.WineCategoryID = Convert.ToInt32(dt.Rows[0]["WineCategoryID"].ToString()); JsonSerializer myJson = new JsonSerializer(); wineCategory.WineCategoryName = myJson.Deserialize <WineCategoryNameModel>(dt.Rows[0]["WineCategoryName"].ToString()); wineCategory.ImageUrl = dt.Rows[0]["ImageUrl"].ToString(); wineCategory.IsDelete = Convert.ToBoolean(dt.Rows[0]["IsDelete"]); } return(wineCategory); }
public Boolean CargaParametrosGenerales(out string sError) { sError = ""; Boolean res; DataTable dt = null; string codError = ""; SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Consultar("USP_SEL_PARAMETROS_GENERALES_01", out dt, out codError, out sError); if (!res) { return(false); } System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); List <Dictionary <object, string> > rows = new List <Dictionary <object, string> >(); Dictionary <object, string> row; foreach (DataRow dr in dt.Rows) { row = new Dictionary <object, string>(); foreach (DataColumn col in dt.Columns) { row.Add(col.ColumnName, dr[col].ToString()); } rows.Add(row); } this.parametrosGeneralesJson = rows; return(true); }
public void SelectButtonOnClick() { SqlAccess sql = new SqlAccess(); string[] selMessage = new string[3]; DataSet ds = sql.Select(inputSelTable.text); if (ds != null) { DataTable table = ds.Tables[0]; int i = 1; foreach (DataRow dataRow in table.Rows) { selectResult.text += i + ":"; i++; foreach (DataColumn dataColumn in table.Columns) { //Debug.Log(dataRow[dataColumn]); selectResult.text += " " + dataRow[dataColumn].ToString(); } selectResult.text += "\n"; } } sql.Close(); }
public void UpdateData(WineCategoryDetailModel model) { List <string> sqls = new List <string>(); List <SqlParameter[]> cmdParms = new List <SqlParameter[]>(); StringBuilder str = new StringBuilder(); str.AppendLine("UPDATE WineCategory SET "); str.AppendLine(" WineCategoryName=@WineCategoryName "); str.AppendLine(" ,IsDelete=@IsDelete "); str.AppendLine(" ,ImageUrl=@ImageUrl "); str.AppendLine(" ,UpdateTime=getdate() "); str.AppendLine(" ,UpdateUser=@UpdateUser "); str.AppendLine(" where WineCategoryID=@WineCategoryID "); SqlParameter[] paras = new SqlParameter[5]; JsonSerializer myJsonSerializer = new JsonSerializer(); string wineCategoryName = myJsonSerializer.Serialize <WineCategoryNameModel>(model.WineCategoryName); paras[0] = new SqlParameter("@WineCategoryName", Common.VariableConvert.ConvertStringToDBValue(wineCategoryName)); paras[1] = new SqlParameter("@IsDelete", Common.VariableConvert.BitConverter(model.IsDelete)); paras[2] = new SqlParameter("@ImageUrl", Common.VariableConvert.ConvertStringToDBValue(model.ImageUrl)); paras[3] = new SqlParameter("@UpdateUser", Common.VariableConvert.ConvertStringToDBValue(model.UpdateUser)); paras[4] = new SqlParameter("@WineCategoryID", model.WineCategoryID); sqls.Add(str.ToString()); cmdParms.Add(paras); SqlAccess mySqlAccess = new SqlAccess(); mySqlAccess.ExecuteNonQuerys(sqls, cmdParms); }
void Start() { var sql = new SqlAccess(); sql.Create("tableTest1", col, colType); sql.Insert("tableTest1", values); sql.Update("tableTest1", new string[] { "age" }, new string[] { "18" }, "id", "1"); //sql.Delete("tableTest1", new string[] { "id" }, new string[] { "1" }); // 获取查询结果保存到DataSet变量 DataSet ds = sql.Select("tableTest1", "age", "id = 1"); if (ds != null) { // 创建临时表保存查询结果 DataTable table = ds.Tables[0]; // 遍历查询结果 并输出 foreach (DataRow row in table.Rows) { foreach (DataColumn column in table.Columns) { Debug.Log(row[column]); } } } }
public List <LibraryTypeModel> GetGameTypeItems(int level, int parentLevel = 0) { string sql = string.Format(@"select * from noveltype where [level]={0}", level); if (parentLevel != 0) { sql += " and parentLevel=" + parentLevel; } List <LibraryTypeModel> list = new List <LibraryTypeModel>(); DataTable dt = new DataTable(); SqlAccess.QueryDt(dt, sql); for (int i = 0; i < dt.Rows.Count; i++) { LibraryTypeModel typeModel = null; typeModel = new LibraryTypeModel() { ID = Normal.ParseInt(dt.Rows[i]["ID"]), Name = Normal.ListStr(dt.Rows[i]["Name"]), Level = Normal.ParseInt(dt.Rows[i]["Level"]), ParentLevel = Normal.ParseInt(dt.Rows[i]["ParentLevel"]) }; list.Add(typeModel); } return(list); }
public Boolean cargarTareasUsuarioRetiro(string id, out string sErrors) { sErrors = ""; Boolean res; DataTable dt = null; string codError = ""; SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Consultar("USP_SEL_LISTA_TO_DO_02", out dt, out codError, out sErrors, id, GetUserName()); if (!res) { return(false); } System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); List <Dictionary <object, string> > rows = new List <Dictionary <object, string> >(); Dictionary <object, string> row; foreach (DataRow dr in dt.Rows) { row = new Dictionary <object, string>(); foreach (DataColumn col in dt.Columns) { row.Add(col.ColumnName, dr[col].ToString()); } rows.Add(row); } this.TareasporUsuarioRetiroJson = rows; return(true); }
public Boolean ModificarNegocioPais(List <iNegocioPais> negociopaisJson, out string sError) { sError = ""; Boolean res; var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }); var serializer = new XmlSerializer(negociopaisJson.GetType()); var settings = new XmlWriterSettings(); settings.Indent = false; settings.OmitXmlDeclaration = true; string xmlVar = ""; using (var stream = new System.IO.StringWriter()) using (var writer = XmlWriter.Create(stream, settings)) { serializer.Serialize(writer, negociopaisJson, emptyNamepsaces); xmlVar = stream.ToString(); } SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Ejecutar("USP_UPD_NEGOCIO_PAIS_00", out sError, xmlVar, System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split('\\').Last()); if (!res) { return(false); } return(true); }
public ActionResult UserStatistics() { List <UserStatsModel> stats = new List <UserStatsModel>(); List <CreateUser> listUser; using (IDbConnection db = new SqlConnection(SqlAccess.GetConnectionString())) { listUser = db.Query <CreateUser>($"Select * from dbo.UserTable").ToList(); } for (int i = 0; i < listUser.Count; i++) { UserStatsModel mod = new UserStatsModel(); mod.ID = listUser[i].ID; mod.Username = listUser[i].Username; mod.Date = listUser[i].Date; mod.DateModified = listUser[i].DateModified; mod.LastLogin = listUser[i].LastLogin; mod.LastSignout = listUser[i].LastSignout; mod.LoginAmount = listUser[i].LoginAmount; mod.LoginFails = listUser[i].LoginFails; stats.Add(mod); } return(View(stats)); }
public ActionResult EditUser(int id) { List <CreateUser> editUser; using (IDbConnection db = new SqlConnection(SqlAccess.GetConnectionString())) { editUser = db.Query <CreateUser>($"Select * from dbo.Usertable Where ID = @ID", new { ID = id }).ToList(); } EditUserModel EditView = new EditUserModel(); EditView.Date_Modified = DateTime.Now; EditView.FirstName = editUser[0].FirstName; EditView.LastName = editUser[0].LastName; EditView.Email = editUser[0].Email; EditView.Username = editUser[0].Username; EditView.Role = editUser[0].Role; EditView.Phone = editUser[0].Phone; EditView.Active = editUser[0].Active; EditView.Address = editUser[0].Address; EditView.City = editUser[0].City; EditView.State = editUser[0].State; EditView.ZIP_Code = editUser[0].ZIP_Code; return(View(EditView)); }
private int getCateOgryID(string sCategoryName) { int iCategoryID; Log.WriteLog(LogType.Trace, "come in getCateOgryID"); /*获取category的id*/ string sSql = "select CategoryID from Category where CategoryName = '" + sCategoryName + "';"; try { DataSet stDs = SqlAccess.GetDataSet(sSql.ToString()); if (stDs.Tables[0].Rows.Count != 1) { Log.WriteLog(LogType.Trace, "error:there is not category with name[" + sCategoryName + "], the impossible"); MessageBox.Show("error:there is not category with name[" + sCategoryName + "], the impossible"); return(0); } iCategoryID = Int32.Parse(stDs.Tables[0].Rows[0]["CategoryID"].ToString()); Log.WriteLog(LogType.Trace, "success to get category id[" + iCategoryID + "] with name[" + sCategoryName + "]"); return(iCategoryID); } catch (Exception ex) { MessageBox.Show("error to get category with name[" + sCategoryName + "]"); return(0); } }
public System.Data.DataTable GetList(string macn) { SqlAccess access = new SqlAccess(); DataTable dt = access.ExecuteStore("sp_PhongbanGetChinhanh", new string[] { "@MaCN" }, new object[] { macn }); return(dt); }
private int getBrandID(string sBrandName) { Log.WriteLog(LogType.Trace, "come in getBrandID"); int iBrandID; /*获取brand的id*/ string sSql = "select BrandID from Brand where BrandName = '" + sBrandName + "';"; try { DataSet stDs = SqlAccess.GetDataSet(sSql.ToString()); if (stDs.Tables[0].Rows.Count != 1) { Log.WriteLog(LogType.Trace, "error:there is not brand with name[" + sBrandName + "], the impossible"); MessageBox.Show("error:there is not brand with name[" + sBrandName + "], the impossible"); return(0); } iBrandID = Int32.Parse(stDs.Tables[0].Rows[0]["BrandID"].ToString()); Log.WriteLog(LogType.Trace, "success to get brand id[" + iBrandID + "] with name[" + sBrandName + "]"); return(iBrandID); } catch (Exception ex) { MessageBox.Show("error to get brand with name[" + CategoryName + "]"); return(0); } }
public List <WineCategoryDetailModel> GetCategorys() { StringBuilder sql = new StringBuilder(); sql.AppendLine("SELECT "); sql.AppendLine(" WineCategoryID, WineCategoryName, ImageUrl"); sql.AppendLine(" FROM WineCategory WITH(NOLOCK)"); sql.AppendLine(" WHERE IsDelete = 0"); SqlAccess mySqlAccess = new SqlAccess(); DataSet ds = mySqlAccess.ExecuteAdapter(sql.ToString()); List <WineCategoryDetailModel> categorys = new List <WineCategoryDetailModel>(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow dw in ds.Tables[0].Rows) { WineCategoryDetailModel category = new WineCategoryDetailModel(); category.WineCategoryID = Convert.ToInt32(dw["WineCategoryID"]); JsonSerializer myJson = new JsonSerializer(); category.WineCategoryName = myJson.Deserialize <WineCategoryNameModel>(dw["WineCategoryName"].ToString()); category.ImageUrl = dw["ImageUrl"].ToString(); categorys.Add(category); } } return(categorys); }
private int getBarcodeID(string sBarcodeNumber) { Log.WriteLog(LogType.Trace, "come in GetBarcodeID"); int iBarcodeID; /*获取brand的id*/ string sSql = "select BarcodeID from Barcode where BarcodeNumber = '" + sBarcodeNumber + "';"; try { DataSet stDs = SqlAccess.GetDataSet(sSql.ToString()); if (stDs.Tables[0].Rows.Count != 1) { Log.WriteLog(LogType.Trace, "info:there is not barcodeId with name[" + sBarcodeNumber + "], will goto create it"); return(0); } iBarcodeID = Int32.Parse(stDs.Tables[0].Rows[0]["BarcodeID"].ToString()); Log.WriteLog(LogType.Trace, "success to get barcode id[" + iBarcodeID + "] with name[" + sBarcodeNumber + "]"); return(iBarcodeID); } catch (Exception ex) { MessageBox.Show("error to get barcode with name[" + sBarcodeNumber + "]"); return(0); } }
public void InsertData(WineCategoryDetailModel model) { List <string> sqls = new List <string>(); List <SqlParameter[]> cmdParms = new List <SqlParameter[]>(); StringBuilder str = new StringBuilder(); str.AppendLine("Insert into WineCategory"); str.AppendLine(" (WineCategoryName, IsDelete, ImageUrl, CreateTime, CreateUser, UpdateTime, UpdateUser) "); str.AppendLine(" Values (@WineCategoryName, @IsDelete, @ImageUrl, getdate(), @CreateUser,getdate(), @UpdateUser);"); SqlParameter[] paras = new SqlParameter[5]; JsonSerializer myJsonSerializer = new JsonSerializer(); string wineCategoryName = myJsonSerializer.Serialize <WineCategoryNameModel>(model.WineCategoryName); paras[0] = new SqlParameter("@WineCategoryName", Common.VariableConvert.ConvertStringToDBValue(wineCategoryName)); paras[1] = new SqlParameter("@IsDelete", Common.VariableConvert.BitConverter(model.IsDelete)); paras[2] = new SqlParameter("@ImageUrl", Common.VariableConvert.ConvertStringToDBValue(model.ImageUrl)); paras[3] = new SqlParameter("@CreateUser", Common.VariableConvert.ConvertStringToDBValue(model.CreateUser)); paras[4] = new SqlParameter("@UpdateUser", Common.VariableConvert.ConvertStringToDBValue(model.UpdateUser)); sqls.Add(str.ToString()); cmdParms.Add(paras); SqlAccess mySqlAccess = new SqlAccess(); mySqlAccess.ExecuteNonQuerys(sqls, cmdParms); }
public bool Guardar(out string sError) { /* * @param1 VARCHAR(255), --Idserviciodenegoci * @param2 VARCHAR(255), --Nombre * @param3 VARCHAR(255), --Descripcion * @param4 VARCHAR(255), --Fecha * @param5 VARCHAR(255), --Idestado * @param6 VARCHAR(255), --Documentofep * @param7 VARCHAR(255), --Idpercreador * @param8 VARCHAR(255), --Idperasignada * @param9 VARCHAR(255), --Idpersolicitante * @param10 VARCHAR(255), --NEGOCIOS ASOCIADOS * @param11 VARCHAR(255), --USUARIO CREACION */ this.hddProrrata = this.hddProrrata.Replace("!**", "<"); this.hddProrrata = this.hddProrrata.Replace("**!", ">"); string Name = GetUserName(); Boolean res; sError = ""; SqlAccess cDAL = new SqlAccess(dbConn); HttpPostedFileBase a = rutaFEP; res = cDAL.Ejecutar("USP_INS_CREA_PROYECTOS_00", out sError, servicio, nombre, descripcion, fecha, "1", nuevoarchivo, Name, "-1", usuario, negocio, Name, codigo, pais, hddProrrata, usuario, cliente); return(true); }
public bool CargaHeader(string identificador, string tipo, out string sError) { sError = ""; Boolean res; DataTable dt = null; string codError = ""; SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Consultar("USP_SEL_ARBOL_11", out dt, out codError, out sError, identificador, tipo); if (!res) { return(false); } System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); List <Dictionary <object, string> > rows = new List <Dictionary <object, string> >(); Dictionary <object, string> row; foreach (DataRow dr in dt.Rows) { row = new Dictionary <object, string>(); foreach (DataColumn col in dt.Columns) { row.Add(col.ColumnName, dr[col].ToString()); } rows.Add(row); } this.headerJson = rows; return(true); }
public bool AsignarJDP(string idproyecto, string idjefedeproyecto, out string sError) { string Name = GetUserName(); Boolean res; sError = ""; SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Ejecutar("USP_UPD_PROYECTO_00", out sError, idproyecto, idjefedeproyecto, Name); Task t = Task.Factory.StartNew(() => { DataTable dtt = null; String sErrort = ""; string codError = ""; cDAL = new SqlAccess(dbConn); res = cDAL.Consultar("USP_SEL_ALERTAS_EMAIL_00", out dtt, out codError, out sErrort, idproyecto, "PROY"); string email, asunto, cuerpo; EnviarMail oMail = new EnviarMail(); foreach (DataRow row in dtt.Rows) { email = row.ItemArray[0].ToString(); asunto = row.ItemArray[1].ToString(); cuerpo = row.ItemArray[2].ToString(); oMail.enviar(email, asunto, cuerpo); } }); return(true); }
public int UserType(LoginModule LoginInfo) { StringBuilder str = new StringBuilder(); str.AppendLine("select Role from LoginUser where IsDelete=0 and Username=@UserName"); SqlParameter[] paras = new SqlParameter[1]; paras[0] = new SqlParameter("@UserName", Common.VariableConvert.ConvertStringToDBValue(LoginInfo.UserName)); SqlAccess mySqlAccess = new SqlAccess(); DataSet myds = mySqlAccess.ExecuteAdapter(str.ToString(), paras); if (myds.Tables[0] != null && myds.Tables[0].Rows.Count > 0) { if (myds.Tables[0].Rows[0].ItemArray[0].ToString().Trim() == "admin") { return(1); } else if (myds.Tables[0].Rows[0].ItemArray[0].ToString().Trim() == "superuser") { return(2); } } return(3); }
/// <summary> /// 初始化设备信息列表“获取数据、更新表格 /// </summary> public void InitDeviceInfoList(int deviceIndex, bool isRefresh = false) { tableName_realtime = GlobalData.Tables[deviceIndex]; tableName_limit = tableName_realtime.Replace("_realtime", "_limit"); //查询标题 string titleQuery = "SELECT * FROM " + tableName_limit + " WHERE options = 'cn'"; DataSet title = SqlAccess.ExecuteQuery(titleQuery); //查询id string idQuery = "SELECT max(_id) FROM " + tableName_realtime; DataSet dsID = SqlAccess.ExecuteQuery(idQuery); if (dsID.Tables.Count > 0) { DataTable table = dsID.Tables[0]; if (table.Rows.Count > 0) { string id = table.Rows[0][0].ToString(); if (!string.IsNullOrEmpty(id)) { //查询实时值 string valueQuery = "SELECT * FROM " + tableName_realtime + " WHERE _id=" + id; DataSet value = SqlAccess.ExecuteQuery(valueQuery); if (isRefresh) { UpdateForm(value); } else { InitDeviceInfoForm(title, value); } } } } }
/*处理添加setting按钮点击事件*/ private void addSettings_add_click(object sender, EventArgs e) { StringBuilder sLogStr = new StringBuilder(); Log.WriteLog(LogType.Trace, "come in addSettings_add_click"); int iIdx = 0; int iSettingsId = 0; /*添加settings记录*/ if (!SqlAccess.SA_AddSettings(comboBoxStore.Text, giStoreId, txtSettingsName.Text, ref iSettingsId)) { Log.WriteLog(LogType.Error, "Error to call SqlAccess.SA_AddSettings"); return; } /*遍历reader数组,添加reader记录*/ for (iIdx = 0; iIdx < reader.Count; iIdx++) { sLogStr.Length = 0; sLogStr.AppendFormat("goto add reader with indxe[{0}]", iIdx); Log.WriteLog(LogType.Trace, sLogStr); if (!SqlAccess.SA_AddReader(reader[iIdx], iSettingsId)) { Log.WriteLog(LogType.Error, "Error to call SqlAccess.SA_AddSettings"); return; } } MessageBox.Show(Macro.SUCCESS_ADD_SETTING); }
private bool AccountNumberIsFound(string NumberChoosen) { bool found = false; if (NumberChoosen != null) { SqlConnection con = new SqlConnection(SqlAccess.GetConnectionString()); SqlCommand cmd = new SqlCommand("Select count(*) from dbo.ChartOfAccounts where AccountNumber = @Num", con); // SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=True"); //SqlCommand cmd = new SqlCommand("Select count(*) from CreateUsers where Username= @Username", con); cmd.Parameters.AddWithValue("@Num", NumberChoosen); con.Open(); int result = (int)cmd.ExecuteScalar(); if (result != 0) { found = true; } else { found = false; } con.Close(); } return(!found); }
public Boolean CargaServicios(string idCotizacion, out string sError) { sError = ""; Boolean res; DataTable dt = null; string codError = ""; SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Consultar("USP_SEL_SERVICIO_00", out dt, out codError, out sError, idCotizacion); if (!res) { return(false); } System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); List <Dictionary <object, string> > rows = new List <Dictionary <object, string> >(); Dictionary <object, string> row; foreach (DataRow dr in dt.Rows) { row = new Dictionary <object, string>(); foreach (DataColumn col in dt.Columns) { row.Add(col.ColumnName, dr[col].ToString()); } rows.Add(row); } this.serviciosJson = rows; return(true); }
private void TestSQL() { try { SqlAccess sql = new SqlAccess(); //sql.CreateTableAutoID("user",new string[]{"id","name","qq","email","blog"}, new string[]{"int","text","text","text","text"}); //sql.CreateTable("user",new string[]{"name","qq","email","blog"}, new string[]{"text","text","text","text"}); sql.InsertInto("user", new string[] { "name", "qq", "email", "blog" }, new string[] { "circle", "289187120", "*****@*****.**", "circle.com" }); sql.InsertInto("user", new string[] { "name", "qq", "email", "blog" }, new string[] { "circle01", "34546546", "*****@*****.**", "circle01.com" }); DataSet ds = sql.SelectWhere("user", new string[] { "name", "qq" }, new string[] { "id" }, new string[] { "!=" }, new string[] { "1" }); if (ds != null) { DataTable table = ds.Tables[0]; foreach (DataRow row in table.Rows) { foreach (DataColumn column in table.Columns) { Debug.Log(row[column]); } } } sql.UpdateInto("user", new string[] { "name", "qq" }, new string[] { "'circle01'", "'11111111'" }, "email", "'*****@*****.**'"); sql.Delete("user", new string[] { "id", "email" }, new string[] { "1", "'*****@*****.**'" }); sql.Close(); } catch (Exception e) { Error = e.Message; } }
public Boolean SolicitarDescuento(string id, string comentarios, out string sErrors) { sErrors = ""; String usrCreacion = GetUserName(); //System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split('\\').Last(); DataTable dtSolitante = new DataTable(); SqlAccess comCotiz = new SqlAccess(dbConn); Boolean result = comCotiz.Ejecutar("USP_UPD_ESTADO_COT_01", out sErrors, id, comentarios, "17", usrCreacion); if (!result) { return(false); } Task t = Task.Factory.StartNew(() => { Boolean res; DataTable dtt = null; string codError = ""; String sErrorst = ""; SqlAccess cDAL = new SqlAccess(dbConn); res = cDAL.Consultar("USP_SEL_ALERTAS_EMAIL_00", out dtt, out codError, out sErrorst, id, "VER"); string email, asunto, cuerpo; EnviarMail oMail = new EnviarMail(); foreach (DataRow row in dtt.Rows) { email = row.ItemArray[0].ToString(); asunto = row.ItemArray[1].ToString(); cuerpo = row.ItemArray[2].ToString(); oMail.enviar(email, asunto, cuerpo); } }); return(true); }
void Awake() { // 连接数据库 mysqldb = new SqlAccess(); }