public DataTable ExecuteSelectQuery(NpgsqlCommand command, NpgsqlConnection conn) { try { if (conn == null) { return null; } DataTable dataTable = new DataTable(); DataSet dataSet = new DataSet(); NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter(command); dataSet.Reset(); dataAdapter.Fill(dataSet); dataTable = dataSet.Tables[0]; conn.Close(); return dataTable.Rows.Count <= 0 ? null : dataTable; } catch (NpgsqlException ex) { Console.WriteLine(ex.Message); return null; } }
private void btExecute_Click(object sender, System.EventArgs e) { try { ResultDS.Reset(); var builder = BuildSQL(); var builderResult = builder.Result; CheckConnection(); var command = _connection.CreateCommand(); command.CommandText = builderResult.Statement; foreach (QueryParam param in builderResult.Params) { command.Parameters.Add(new SqlParameter("@" + param.Id, param.Value)); } var resultDA = new SqlDataAdapter(command); resultDA.Fill(ResultDS, "Result"); dataGrid1.DataSource = ResultDS.Tables[0].DefaultView; CloseConnections(); ShowExportPanel(); } catch (Exception error) { //if some error occurs just show the error message MessageBox.Show(error.Message); } }
protected void SaveVar_Click(Object sender, EventArgs e) { #region 保存变量修改 dsSrc = LoadDataTable(); int row = 0; //bool error = false; foreach (object o in DataGrid1.GetKeyIDArray()) { int id = int.Parse(o.ToString()); string variablename = DataGrid1.GetControlValue(row, "variablename").Trim(); string variablevalue = DataGrid1.GetControlValue(row, "variablevalue").Trim(); if (variablename == "" || variablevalue == "") { //error = true; continue; } foreach (DataRow dr in dsSrc.Tables["TemplateVariable"].Rows) { if (id.ToString() == dr["id"].ToString()) { dr["variablename"] = variablename; dr["variablevalue"] = variablevalue; break; } } try { if (dsSrc.Tables[0].Rows.Count == 0) { File.Delete(Utils.GetMapPath("../../templates/" + DNTRequest.GetString("path") + "/templatevariable.xml")); dsSrc.Reset(); dsSrc.Dispose(); } else { string filename = Server.MapPath("../../templates/" + DNTRequest.GetString("path") + "/templatevariable.xml"); dsSrc.WriteXml(filename); dsSrc.Reset(); dsSrc.Dispose(); Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); cache.RemoveObject("/Forum/" + DNTRequest.GetString("path") + "/TemplateVariable"); base.RegisterStartupScript("PAGE", "window.location.href='global_templatevariable.aspx?templateid=" + DNTRequest.GetString("templateid") + "&path=" + DNTRequest.GetString("path") + "&templatename=" + DNTRequest.GetString("templatename") + "';"); } } catch { base.RegisterStartupScript("", "<script>alert('无法更新数据库.');window.location.href='global_templatevariable.aspx?templateid=" + DNTRequest.GetString("templateid") + "&path=" + DNTRequest.GetString("path") + "&templatename=" + DNTRequest.GetString("templatename") + "';</script>"); return; } row++; } #endregion }
protected void Button1_Click(object sender, EventArgs e) { id = DropDownList1.SelectedItem.ToString(); DataSet ds = new DataSet(); DataSet ds1 = new DataSet(); DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=projekt;Database=projekt;"); conn.Open(); // quite complex sql statement string sql = "SELECT id_wyp FROM wyp_sali where id_sali='" + id + "'"; // data adapter making request from our connection NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn); // i always reset DataSet before i do // something with it.... i don't know why :-) ds.Reset(); // filling DataSet with result from NpgsqlDataAdapter da.Fill(ds); // since it C# DataSet can handle multiple tables, we will select first dt = ds.Tables[0]; int count = dt.Rows.Count; for (int i = 0; i < count; i++) { string current = dt.Rows[i][0].ToString(); string sqlc = "SELECT * FROM wyposazenie where id_wyp='" + current + "'"; NpgsqlDataAdapter dac = new NpgsqlDataAdapter(sqlc, conn); dac.Fill(ds1); dt1 = ds1.Tables[0]; } GridView1.DataSource = dt1; GridView1.DataBind(); conn.Close(); }
public Double obtenerCajaActual(DateTime fecha) { try { FuncionesGenerales.FuncionesGenerales fg = new FuncionesGenerales.FuncionesGenerales(); ConectarBD con = new ConectarBD(); DataSet Ds = new DataSet(); Double importe = 0.00; String sSQL = ""; sSQL = "EXEC dbo.adp_ObtenerCajaActual"; sSQL = sSQL + " @fecha_mov = " + fg.fcSql(fecha.ToString(), "DATETIME"); Ds.Reset(); Ds = con.ejecutarQuerySelect(sSQL); if (Ds.Tables[0].Rows.Count > 0) { importe = Double.Parse(Ds.Tables[0].Rows[0]["TOTAL"].ToString()); } return importe; } catch (Exception e) { throw new System.ArgumentException("[Error] - [" + e.Message.ToString() + "]"); } }
public static DataTable GetDataTable(string query) { DataSet tempDataSet = new DataSet(); SqliteDataAdapter tempAdapter = null; try { __connection.Open(); tempAdapter = new SqliteDataAdapter(query, __connection); tempDataSet.Reset(); tempAdapter.Fill(tempDataSet); } catch (Exception ex) { throw new InvalidOperationException("Error in the DataBase", ex); } finally { if (tempAdapter != null) tempAdapter.Dispose(); __connection.Close(); } return tempDataSet.Tables[0]; }
public DataTable consultar(String query) { conectar(); SQLiteDataAdapter db = new SQLiteDataAdapter(query, conexion); DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Reset(); db.Fill(ds); dt = ds.Tables[0]; desconectar(); return dt; /* SQLiteCommand cmd = new SQLiteCommand(query, conexion); SQLiteDataReader datos = cmd.ExecuteReader(); // Leemos los datos de forma repetitiva while (datos.Read()) { string codigo = Convert.ToString(datos[0]); string nombre = Convert.ToString(datos[1]); // Y los mostramos Console.WriteLine("Codigo: {0}, Nombre: {1}", codigo, nombre); }*/ }
public DataRow[] drExecute(string FileData, string sSql) { DataRow[] datarows = null; SQLiteDataAdapter dataadapter = null; DataSet dataset = new DataSet(); DataTable datatable = new DataTable(); try { using (SQLiteConnection con = new SQLiteConnection()) { con.ConnectionString = @"Data Source=" + FileData + "; Version=3; New=False;"; con.Open(); using (SQLiteCommand sqlCommand = con.CreateCommand()) { dataadapter = new SQLiteDataAdapter(sSql, con); dataset.Reset(); dataadapter.Fill(dataset); datatable = dataset.Tables[0]; datarows = datatable.Select(); k = datarows.Count(); } con.Close(); } } catch(Exception ex) { // throw ex; datarows = null; } return datarows; }
public void GetUserDetail() { try { if (Session["userID"] != null && Session["username"] != null) { System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = conf.GetUserDetail(Session["userID"].ToString()); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { txtemail.Text = ds.Tables[0].Rows[0]["EmailAddress"].ToString(); } } } else { Response.Redirect("User_Login.aspx"); } } catch (Exception ex) { throw ex; } }
public void initTexts(object[] dataRow) { if (dataRow.Length == 0) { return; } this.dateTimePicker2.Value = Convert.ToDateTime(dataRow[1].ToString()); this.dateTimePicker3.Value = Convert.ToDateTime(dataRow[2].ToString()); this.textBox9.Text = dataRow[3].ToString(); DataTable dt; string id = dataRow[0].ToString(); if (!String.Empty.Equals(id)) { SqlDataAdapter adapter2 = new SqlDataAdapter(String.Format("EXEC [dbo].ksiazki_w_promocji {0}", id), conn); DataSet set2 = new DataSet(); set2.Reset(); adapter2.Fill(set2); dt = set2.Tables[0]; this.checkedListBox2.DataSource = dt; this.checkedListBox2.DisplayMember = "tytul"; this.checkedListBox2.ValueMember = "isbn"; } else { dt = new DataTable(); } for (int i = 0; i < checkedListBox2.Items.Count; i++) { checkedListBox2.SetItemChecked(i, true); } }
//Activate This Construntor to log All To Standard output //public TestClass():base(true){} //Activate this constructor to log Failures to a log file //public TestClass(System.IO.TextWriter tw):base(tw, false){} //Activate this constructor to log All to a log file //public TestClass(System.IO.TextWriter tw):base(tw, true){} //BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES public void run() { Exception exp = null; DataTable dt1 = GHTUtils.DataProvider.CreateParentDataTable(); DataTable dt2 = GHTUtils.DataProvider.CreateChildDataTable(); dt1.PrimaryKey = new DataColumn[] {dt1.Columns[0]}; dt2.PrimaryKey = new DataColumn[] {dt2.Columns[0],dt2.Columns[1]}; DataRelation rel = new DataRelation("Rel",dt1.Columns["ParentId"],dt2.Columns["ParentId"]); DataSet ds = new DataSet(); ds.Tables.AddRange(new DataTable[] {dt1,dt2}); ds.Relations.Add(rel); ds.Reset(); try { BeginCase("Reset - Relations"); Compare(ds.Relations.Count ,0 ); } catch(Exception ex) {exp = ex;} finally {EndCase(exp); exp = null;} try { BeginCase("Reset - Tables"); Compare(ds.Tables.Count ,0 ); } catch(Exception ex) {exp = ex;} finally {EndCase(exp); exp = null;} }
protected void Page_Load(object sender, EventArgs e) { string rola; FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity; FormsAuthenticationTicket bilet = id.Ticket; Label1.Text = "Zalogowany jako: " + User.Identity.Name; // Get the stored user-data, in this case, our roles rola = bilet.UserData; if (rola != "admins") Response.Redirect("index.aspx"); DataSet ds = new DataSet(); DataTable dt = new DataTable(); NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=projekt;Database=projekt;"); conn.Open(); // quite complex sql statement string sql = "SELECT * FROM sala"; // data adapter making request from our connection NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn); // i always reset DataSet before i do // something with it.... i don't know why :-) ds.Reset(); // filling DataSet with result from NpgsqlDataAdapter da.Fill(ds); // since it C# DataSet can handle multiple tables, we will select first dt = ds.Tables[0]; // connect grid to DataTable GridView1.DataSource = dt; GridView1.DataBind(); // since we only showing the result we don't need connection anymore conn.Close(); }
public static DataSet ExecuteDataSet(string SqlRequest, SQLiteConnection Connection) { DataSet dataSet = new DataSet(); dataSet.Reset(); SQLiteCommand cmd = new SQLiteCommand(SqlRequest, Connection); try { Connection.Open(); SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(cmd); dataAdapter.Fill(dataSet); } catch (SQLiteException ex) { Log.Write(ex); //Debug.WriteLine(ex.Message); throw; // пересылаем исключение на более высокий уровень } finally { Connection.Dispose(); } return dataSet; }
public void initData() { SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM [Promocje]", conn); DataSet set = new DataSet(); set.Reset(); adapter.Fill(set); DataTable datable = set.Tables["Table"]; int i = 0; this.max = datable.Rows.Count; DBHelper.Log(this.max.ToString()); datas = new object[max][]; foreach (DataRow dr in datable.Rows) { datas[i] = new object[6]; int v = 0; foreach (string p in columns) { datas[i][v] = dr[p]; v++; } i++; } dualNumerator = new DualNumerator(datas, max); initTexts(dualNumerator.GetFirst()); }
public static IEnumerable<TerrainService.shPoint> getPolygonPoints(string polygon_guid) { List<TerrainService.shPoint> pntsList = new System.Collections.Generic.List<TerrainService.shPoint>(); string sql = "select * from polygon_points where polygon_guid='" + polygon_guid + "' order by point_num"; using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection)) { DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; if (dt == null || dt.Rows == null || dt.Rows.Count == 0) { return null; } foreach (DataRow row in dt.Rows) { TerrainService.shPoint mp = new TerrainService.shPoint(); mp.x = System.Convert.ToDouble(row["pointx"]); mp.y = System.Convert.ToDouble(row["pointy"]); pntsList.Add(mp); } } return pntsList; }
public void initData() { Auth a = Auth.GetInstance(); string strcmd = "SELECT * FROM [Zamowienia] WHERE 1=1 "; if (!a.IsAdmin()) { strcmd += String.Format(" AND id_user = {0}", a.selectedUserId); } SqlDataAdapter adapter = new SqlDataAdapter(strcmd, conn); DataSet set = new DataSet(); set.Reset(); adapter.Fill(set); DataTable datable = set.Tables["Table"]; int i = 0; this.max = datable.Rows.Count; DBHelper.Log(this.max.ToString()); datas = new object[max][]; foreach (DataRow dr in datable.Rows) { datas[i] = new object[columns.Length]; int v = 0; foreach (string p in columns) { datas[i][v] = dr[p]; v++; } i++; } dualNumerator = new DualNumerator(datas, max); initTexts(dualNumerator.GetFirst()); }
public void extraerInformacion() { SQLiteConnection conexion = new SQLiteConnection("Data Source=../../archivos/bd.sqlite3;Version=3"); conexion.Open(); //Se conecta a la BD y trae los datos para, luego, llenar el DataSet string strSQL = "select * from usuario"; SQLiteDataAdapter db = new SQLiteDataAdapter(strSQL, conexion); DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Reset(); db.Fill(ds); dt = ds.Tables[0]; //imprimimos los rows... habra que crear una clase para todas estas operaciones foreach (DataRow a in dt.Rows) { Console.Write("Columna :" + a["id"] + "\n"); } conexion.Close(); Console.ReadLine(); }
public void CheckData(int orgid,int evid) { DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("select * from reg_parameter where rp_org_id=" + orgid + " and rp_ev_id=" + evid, ob.cn); ds.Reset(); da.Fill(ds); btnSave.Visible = false; btnUpdate.Visible = false; btnReset.Visible = false; if (ds.Tables[0].Rows.Count > 0) { txtMax_rg.Text = ds.Tables[0].Rows[0]["rp_max_participants"].ToString(); txtMax_rg.Enabled = false; FillData(rblCan_rg, ds.Tables[0].Rows[0]["rp_is_register_more"].ToString()); rblCan_rg.Enabled = false; if (rblCan_rg.SelectedValue == "1") { how_many.Visible = true; how_many_txtbx.Visible = true; txtHow_many.Text = ds.Tables[0].Rows[0]["rp_reg_howmany"].ToString(); txtHow_many.Enabled = false; } else { how_many.Visible = false; how_many_txtbx.Visible = false; } FillData(rblIs_waitlist, ds.Tables[0].Rows[0]["rp_is_wtlisting"].ToString()); rblIs_waitlist.Enabled = false; FillData(rblIs_onsite, ds.Tables[0].Rows[0]["rp_is_onsite_reg"].ToString()); rblIs_onsite.Enabled = false; FillData(rblCan_rgwop, ds.Tables[0].Rows[0]["rp_reg_without_pay"].ToString()); rblCan_rgwop.Enabled = false; if (rblCan_rgwop.SelectedValue == "1") { no_of_days.Visible = true; days_txtbx.Visible = true; txtNo_of_days.Text = ds.Tables[0].Rows[0]["rp_no_days_pay"].ToString(); txtNo_of_days.Enabled = false; } else { no_of_days.Visible = false; days_txtbx.Visible = false; } } else { btnSave.Visible = true; btnEdit.Visible = false; btnReset.Visible = true; } }
public void Fillcart() { if (Session["userID"] != null && Session["username"] != null) { //Server.Transfer(""); decimal total = 0; Label1.Text = Session["userName"].ToString(); Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_Addtocart_detailwithuserid(Session["userID"].ToString()); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { //txtqty.Text = ds.Tables[0].Rows[0]["StockQuantity"].ToString(); //h1.Value = ds.Tables[0].Rows[0]["Product_id"].ToString(); ////txtqty.Text = ds.Tables[0].Rows[0]["Quantity"].ToString(); ////productdesc.Text = ds.Tables[0].Rows[0]["Product_description"].ToString(); ////productName.Text = ds.Tables[0].Rows[0]["Product_Name"].ToString(); ////Prd_Img.ImageUrl = "product/"+ds.Tables[0].Rows[0]["Product_Image"].ToString(); rptcartlist.DataSource = ds.Tables[0]; rptcartlist.DataBind(); btnGotoCart.Visible = true; Countproduct.Text = ds.Tables[0].Rows.Count.ToString(); foreach (RepeaterItem item in rptcartlist.Items) { Label lblprice = (Label)item.FindControl("lblprice"); Label lblTotal = (Label)rptcartlist.Controls[rptcartlist.Controls.Count - 1].FindControl("lblTotal"); Label lblqty = (Label)item.FindControl("lblqty"); // Label lbltotal = (Label)item.FindControl("lbltotal"); decimal subtotal = Convert.ToDecimal(lblprice.Text) * Convert.ToInt32(lblqty.Text); total += subtotal; //string qty = lblqty.Text; //lblqty.Text = qty.ToString("0.##"); lblTotal.Text = total.ToString("0.00"); } lnklogin.Visible = false; } else if (ds.Tables[0].Rows.Count == 0) { rptcartlist.DataSource = null; rptcartlist.DataBind(); lblMessage.Visible = true; countdiv.Visible = false; lblMessage.Text = "You have no items in your shopping cart."; btnGotoCart.Visible = false; } } } else { //Response.Redirect("User_Login.aspx"); lblMessage.Visible = true; lblMessage.Text = "You have no items in your shopping cart."; btnGotoCart.Visible = false; } }
public void read(string query1, string value1) { da = new SqlDataAdapter(query1 + value1, cn); ds = new DataSet(); ds.Clear(); ds.Reset(); da.Fill(ds); }
private void actualizarGanancia() { Entidades.Venta entVentas = new Entidades.Venta(); DataSet Ds = new DataSet(); Ds.Reset(); Ds = entVentas.obtenerGanancia(DateTime.Parse(dtpFechaCaja.Text.ToString()), DateTime.Parse(dtpFechaCaja.Text.ToString())); lblGanancia.Text = Ds.Tables[0].Rows[0]["Ganancia"].ToString(); }
private void actualizarGanancia() { Entidades.Venta entVentas = new Entidades.Venta(); DataSet Ds = new DataSet(); Ds.Reset(); Ds = entVentas.obtenerGanancia(fg.appFechaSistema(), fg.appFechaSistema()); lblGanancia.Text = Ds.Tables[0].Rows[0]["Ganancia"].ToString(); }
private void actualizarCierreParcial() { Entidades.Caja caja = new Entidades.Caja(); DataSet Ds = new DataSet(); Ds.Reset(); Ds = caja.obtenerCierreParcialCaja(fg.appFechaSistema()); lblCierreParcial.Text = Ds.Tables[0].Rows[0]["Cierre_Parcial"].ToString(); }
public DataSet fetch(string query) { da = new SqlDataAdapter(query, con); ds = new DataSet(); ds.Clear(); ds.Reset(); da.Fill(ds); return ds; }
private void Form1_Load(object sender, EventArgs e) { string sql = "select * from akter"; DataSet ds = new DataSet(); DataTable dt = new DataTable(); NpgsqlConnection conn = new NpgsqlConnection("Server=webblabb.miun.se;Port=5432;Database=pgmvaru_g4;User Id=pgmvaru_g4;Password=trapets;ssl=true"); NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; dataGridView1.DataSource = dt; }
public DataTable readLabeledData() { conn.Open(); string sql = "SELECT * FROM public.\"labeledData\""; NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn); DataSet ds = new DataSet(); ds.Reset(); da.Fill(ds); DataTable dt = new DataTable(); dt = ds.Tables[0]; conn.Close(); return dt; }
public int CountDoc(string query) { SetConnection(); sql_con.Open(); sql_cmd = sql_con.CreateCommand(); DB = new SQLiteDataAdapter(query, sql_con); DataSet DataS = new DataSet(); DataS.Reset(); DB.Fill(DataS); //int t = Convert.ToInt16(DataS.Tables[0].Rows[0][0]); return Convert.ToInt16(DataS.Tables[0].Rows[0][0]); }
private static clsPolygon GetPolygonBySql(string sql) { try { clsPolygon polygon = new clsPolygon(); using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection)) { DataSet dsPol = new DataSet(); DataTable dtPol = new DataTable(); dsPol.Reset(); da.Fill(dsPol); dtPol = dsPol.Tables[0]; if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0) { return null; } foreach (DataRow rowPol in dtPol.Rows) { polygon.PolygonName = rowPol["polygon_name"].ToString(); polygon.PolygonGuid = rowPol["polygon_guid"].ToString(); } } polygon.Points = getPolygonPoints(polygon.PolygonGuid); //YD: // get the polygon's openings polygon.PolygonOpenings = getPolygonOpeningsByPolygon(polygon); // get the escape points for each opening List<clsPolygonOpeningEscapePoint> escapePoints = getPolygonEscapePoints(polygon); polygon.EscapePoints = new Dictionary<int, clsPolygonOpeningEscapePoint>(); foreach (clsPolygonOpeningEscapePoint escapePoint in escapePoints) { polygon.EscapePoints.Add(escapePoint.polygonEdgeNum, escapePoint); } // --- return polygon; } catch (Exception ex) { } return null; }
public static DataSet ExecuteQuery(string query) { DataSet DS = new DataSet(); using (var sql_con = GetConnection()) { sql_con.Open(); var sql_cmd = sql_con.CreateCommand(); var DB = new SQLiteDataAdapter(query, sql_con); DS.Reset(); DB.Fill(DS); sql_con.Close(); } return DS; }
public void fillCat() { Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_categories(); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { rptCat.DataSource = ds.Tables[0]; rptCat.DataBind(); } } }
private void getPage() { Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_page_detail("9"); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { pagecontent.Text = ds.Tables[0].Rows[0]["P_Content"].ToString(); pagename.Text = ds.Tables[0].Rows[0]["P_Name"].ToString(); } } }
public void manipulate(string parma, string val) { try { ds = new DataSet(); ds.Clear(); ds.Reset(); con.Open(); da = new SqlDataAdapter(parma + val, con); da.Fill(ds); con.Close(); } catch (Exception) { // } }
public static DataTable ExecuteSql(string dbConnectionString, string sqlString) { // execute stored procedure using (var conn = new SqlConnection(dbConnectionString)) { conn.Open(); using (var ds = new DataSet()) using (var da = new SqlDataAdapter(sqlString, conn)) { da.SelectCommand.CommandTimeout = 5; ds.Reset(); da.Fill(ds); return ds.Tables[0]; } } }
public DataBase() { datos = new DataSet(); datos.ReadXml(Application.StartupPath + "\\cotizadorxml.xml"); //cargar las configuraciones de la base de datos DataSet conf = new DataSet(); conf.ReadXml(Application.StartupPath + "\\cot_externo.xml"); this.server = conf.Tables[0].Rows[0][0].ToString(); conf.Reset(); conf.ReadXml(Application.StartupPath + "\\cot_conn.xml"); this.user = conf.Tables[0].Rows[0][0].ToString(); this.pwd = conf.Tables[0].Rows[0][1].ToString(); this.bd = conf.Tables[0].Rows[0][2].ToString(); this.conextion = "Server=" + this.server + ";Database=" + this.bd + ";Uid=" + this.user + ";Pwd=" + this.pwd; this.conn = new MySqlConnection(this.conextion); }
private void btnCerrarCaja_Click(object sender, EventArgs e) { try { Boolean deseaModificarUnMovimiento = (MessageBox.Show("¿Desea modificar algún movimiento antes de realizar el Cierre de Caja correspondiente?", "Cierre de Caja.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes); if (deseaModificarUnMovimiento) { frmCaja caja = new frmCaja(); caja.ShowDialog(); } else { Entidades.Caja caja = new Entidades.Caja(); Boolean deseaContinuarConElCierreDeLaCaja = (MessageBox.Show("A continuación se realizará el Cierre de Caja correspondiente al día " + caja.obtenerFechaCajaAbierta() + ". ¿Desea Continuar?", "Cierre de Caja.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes); if (deseaContinuarConElCierreDeLaCaja) { MovimientoCaja movCaja = new MovimientoCaja(); DateTime fecSisActual = fg.appFechaSistema(); String Hora = System.DateTime.Now.TimeOfDay.ToString().Substring(0, 8); String Descripcion = "Cierre de caja del día " + fg.appFechaSistema().ToString(); DataSet Ds = new DataSet(); Ds.Reset(); Ds = caja.obtenerCierreParcialCaja(fg.appFechaSistema()); double valor = double.Parse(Ds.Tables[0].Rows[0]["Cierre_Parcial"].ToString()); movCaja.registrarMovimientoCaja(0, Descripcion, valor, fecSisActual, Hora); ParametrosGenerales pg = new ParametrosGenerales(); pg.modificarEstadoGlobalSistema(0); //CIERRO LA CAJA - ESTADO "0" MessageBox.Show("Se realizó el Cierre de Caja Correctamente.", "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } catch (Exception r) { MessageBox.Show(r.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void GetBanner() { try { Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.Get_Banner(); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { bannerID.DataSource = ds.Tables[0]; bannerID.DataBind(); } } } catch (Exception ex) { throw ex; } }
private void GetNewslimit() { try { Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_brochure_options(4); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { Repeater1.DataSource = ds.Tables[0]; Repeater1.DataBind(); } } } catch (Exception ex) { throw ex; } }
private void GetBrochure() { try { Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_brochure(); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { rpt_Product.DataSource = ds.Tables[0]; rpt_Product.DataBind(); } } } catch (Exception ex) { throw ex; } }
protected void btnGotoCart_Click(object sender, EventArgs e) { if (Session["userID"] != null && Session["username"] != null) { //Server.Transfer(""); Label1.Text = Session["userName"].ToString(); Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_Addtocart_detailwithuserid(Session["userID"].ToString()); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { Response.Redirect("ViewCart.aspx"); } } } else { lblMessage.Visible = true; lblMessage.Text = "There is no Record in Your Shopping Cart."; } }
protected void Page_Load(object sender, EventArgs e) { Config con = new Config(); try { string[] merc_hash_vars_seq; string[] merc_hash_vars_seq1; string merc_hash_string = string.Empty; string merc_hash_string1 = string.Empty; string merc_hash = string.Empty; string order_id = string.Empty; string hash_seq = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10"; string hash_seq1 = "mihpayid|mode|status|unmappedstatus|key|txnid|amount|cardCategory|discount|net_amount_debit|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10|payment_source|PG_TYPE|bank_ref_num|bankcode|error|error_Message|name_on_card|cardnum|issuing_bank|card_type"; bool isTestAccount = Convert.ToBoolean(ConfigurationManager.AppSettings["isTestAccount"]); if (!string.IsNullOrEmpty(Request.QueryString["promo"])) { if (!string.IsNullOrEmpty(Session["userID"].ToString())) { try { // MembershipplanOrdersFields objOrder = CommonFunctions.GetOrderData(Request.QueryString["id"]); string promo = "Promo Code"; PaymentID.InnerHtml = "success"; tid.InnerHtml = promo; } catch (Exception ex) { Response.Write("Something is wrong please try after some time."); } } } else { if (!string.IsNullOrEmpty(Request.QueryString["AddressID"])) { string addressid = Request.QueryString["AddressID"].ToString(); if (Request.Form["status"] == "success") { merc_hash_vars_seq = hash_seq.Split('|'); merc_hash_vars_seq1 = hash_seq1.Split('|'); Array.Reverse(merc_hash_vars_seq); Array.Reverse(merc_hash_vars_seq1); foreach (string merc_hash_var in merc_hash_vars_seq) { merc_hash_string += "|"; merc_hash_string = merc_hash_string + (Request.Form[merc_hash_var] != null ? Request.Form[merc_hash_var] : ""); } foreach (string merc_hash_var in merc_hash_vars_seq1) { merc_hash_string1 += "|"; merc_hash_string1 = merc_hash_string1 + (Request.Form[merc_hash_var] != null ? Request.Form[merc_hash_var] : ""); } string[] aParam = merc_hash_string1.Split('|'); aParam = merc_hash_string1.Split('|'); merc_hash = Generatehash512(merc_hash_string).ToLower(); order_id = Request.Form["txnid"]; string PaymentDt = DateTime.Now.ToString(); string status = ""; if (aParam[31] == "success") { status = "success"; // objOrder.ActivePlan = 1; } else { status = "Failure"; } //string ResponseCode = aParam[34]; //MerchantRefNo.InnerHtml = aParam[34]; //int OrderNo = Convert.ToInt32(aParam[21]); string cardnumber = (aParam[3].Length > 3) ? aParam[3].Substring(aParam[3].Length - 4, 4) : aParam[3]; string cardtype = aParam[1]; string cardname = aParam[4]; Amount.InnerHtml = aParam[24].ToString(); //decimal AmountPaid = Convert.ToDecimal(aParam[25]); //string PaymentMode = aParam[33]; tid.InnerHtml = aParam[28]; string email = aParam[21]; string PaymentType = "PayUmoney"; string OrderNote = string.IsNullOrEmpty(Session["Note"].ToString()) ? " " : Session["Note"].ToString(); //string TransactionID = aParam[34]; PaymentID.InnerHtml = aParam[33]; if (order_id != null) { string ToEmail, Email; Config config = new Config(); System.Data.DataSet dataset = new System.Data.DataSet(); dataset.Reset(); System.Data.DataSet dataset1 = new System.Data.DataSet(); dataset1.Reset(); MailMessage Msg = new MailMessage(); MailMessage adminMsg = new MailMessage(); string body = string.Empty; dataset1 = config.get_Addtocart_detailwithuserid(Session["userID"].ToString()); { if (dataset.Tables.Count > 0) { if (dataset.Tables[0].Rows.Count > 0) { string orderid = dataset.Tables[0].Rows[0]["Orderid"].ToString(); } } System.Data.DataSet dsorderno = new System.Data.DataSet(); dsorderno.Reset(); dsorderno = con.getorderorderno(Session["userID"].ToString()); string OrderNo = ""; if (dsorderno.Tables[0].Rows[0]["Orderid"].ToString() == "") { OrderNo = "001"; } else { OrderNo = dsorderno.Tables[0].Rows[0]["Orderid"].ToString().PadLeft(3, '0'); } int x = helper.ExecuteNonQuery("insert into [dbo].[order] (OrderNo,CustomerID,AddressID,OrderDate,Order_Status,OrderTotalAmount) VALUES('" + OrderNo + "','" + Session["UserID"].ToString() + "','" + addressid + "','" + DateTime.Now + "','" + 0 + "','" + Amount.InnerHtml + "')"); if (x > 0) { System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); System.Data.DataSet ds1 = new System.Data.DataSet(); ds1.Reset(); ds1 = con.getordermaxid(Session["userID"].ToString()); if (ds1.Tables.Count > 0) { if (ds1.Tables[0].Rows.Count > 0) { string orderid = ds1.Tables[0].Rows[0]["Orderid"].ToString(); DataSet dtdate = new DataSet(); dtdate = con.getOrderID(orderid); DateTime orderdate = Convert.ToDateTime(dtdate.Tables[0].Rows[0]["OrderDate"].ToString()); string OrderDate = Convert.ToDateTime(orderdate, CultureInfo.GetCultureInfo("en-US")).ToString("MM/dd/yyyy"); ds = con.GetUserDetail(Session["userID"].ToString()); string vacode = ds.Tables[0].Rows[0]["VACode"].ToString(); System.Data.DataSet ds2 = new System.Data.DataSet(); var templateString = ""; List <ListItem> lst = new List <ListItem>(); ds2.Reset(); ds2 = con.getadmindetail(); DataSet userdetail = new DataSet(); userdetail = con.Getorder(orderid); if (ds2.Tables.Count > 0) { if (ds2.Tables[0].Rows.Count > 0) { string adminmail = ds2.Tables[0].Rows[0]["admin_email"].ToString(); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { decimal total = 0; System.Data.DataSet getdetail = new DataSet(); string userid = Session["userID"].ToString(); getdetail = config.get_Addtocart_detailwithuserid(userid); if (getdetail.Tables.Count > 0) { if (getdetail.Tables[0].Rows.Count > 0) { Repeater rptcart = (Repeater)Master.FindControl("rptcartlist"); if (rptcart != null) { rptcart.DataSource = getdetail.Tables[0]; rptcart.DataBind(); foreach (RepeaterItem item in rptcart.Items) { HiddenField availstock = (HiddenField)item.FindControl("hdnstock"); HiddenField productname = (HiddenField)item.FindControl("hdnproduct"); HiddenField pid = (HiddenField)item.FindControl("lblproid"); Label lblprice = (Label)item.FindControl("lblprice"); Label lblTotal = (Label)rptcart.Controls[rptcart.Controls.Count - 1].FindControl("lblTotal"); Label lblqty = (Label)item.FindControl("lblqty"); decimal subtotal = Convert.ToDecimal(lblprice.Text) * Convert.ToInt32(lblqty.Text); total += subtotal; lblTotal.Text = total.ToString("0.00"); ViewState["PlaceAmount"] = lblTotal.Text; int y = helper.ExecuteNonQuery("update addtocart set OrderID='" + orderid + "' where CustomerID='" + Session["UserID"].ToString() + "' and productid='" + pid.Value + "' AND ADDTOCART.cart_status=0 and orderid=0"); if (y > 0) { } int z = helper.ExecuteNonQuery("insert into orderdetail (OrderID,ProductID,Price,Quantity) values('" + orderid + "','" + pid.Value + "','" + lblprice.Text + "','" + lblqty.Text + "')"); if (z > 0) { } if (availstock.Value != null) { decimal stock = Convert.ToDecimal(availstock.Value); int quantity = Convert.ToInt32(lblqty.Text); decimal availablestock = stock - quantity; int updatestock = helper.ExecuteNonQuery("update products set availablestock='" + availablestock + "' where product_id='" + pid.Value + "' and product_status=1"); if (updatestock > 0) { } } else { } using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/OrderConfirmationTemplate.html"))) { body = reader.ReadToEnd(); } if (userdetail.Tables[0].Rows.Count > 0) { string Name = userdetail.Tables[0].Rows[0]["FirstName"].ToString() + " " + userdetail.Tables[0].Rows[0]["LastName"].ToString(); body = body.Replace("[[vacode]]", vacode); body = body.Replace("[[Name]]", Name); body = body.Replace("[[OrderNo]]", OrderNo); body = body.Replace("[[OrderDate]]", OrderDate); if (userdetail.Tables[0].Rows[0]["Address1"].ToString() == "") { } else { string Address = userdetail.Tables[0].Rows[0]["Address1"].ToString(); body = body.Replace("[[Address]]", Address); } body = body.Replace("[[Contact]]", userdetail.Tables[0].Rows[0]["PhoneNumber"].ToString()); } body = body.Replace("[[total]]", lblTotal.Text); body = body.Replace("[[subtotal]]", lblTotal.Text); body = body.Replace("[[MailTemplateImageURL]]", ConfigurationManager.AppSettings["WebPath"]); //body = body.Replace("[[Items]]", productname.Value); StringBuilder sb = new StringBuilder(); for (var i = 0; i < getdetail.Tables[0].Rows.Count; i++) { sb.Append("<tr style='height: 32px;'>"); sb.Append("<td style='border-bottom: 1px dotted rgb(15, 15, 15); padding: 0pt 10px 0pt 0pt;'> " + getdetail.Tables[0].Rows[i]["product_name"].ToString() + "</td>"); sb.Append("<td style='border-bottom: 1px dotted rgb(15, 15, 15); padding: 0pt 10px 0pt 0pt;'></td>"); sb.Append("<td style='border-bottom: 1px dotted rgb(15, 15, 15); padding: 0pt 10px 0pt 0pt;'> " + getdetail.Tables[0].Rows[i]["MaxQuantity"].ToString() + "</td>"); decimal amount = Convert.ToDecimal(getdetail.Tables[0].Rows[i]["Price"].ToString()) * Convert.ToDecimal(getdetail.Tables[0].Rows[i]["MaxQuantity"].ToString()); string amt = amount.ToString("0.00"); sb.Append("<td style='border-bottom: 1px dotted rgb(15, 15, 15); padding: 0pt 10px 0pt 0pt;'> " + getdetail.Tables[0].Rows[i]["Price"].ToString() + "</td>"); sb.Append("<td style='text-align: right; text-transform: uppercase; border-bottom: 1px dotted rgb(15, 15, 15);'> " + amt + "</td>"); sb.Append("</tr>"); } body = body.Replace("##order.products##", sb.ToString()); } Msg.From = new MailAddress(ConfigurationManager.AppSettings["ContactEmail"]); Msg.To.Add(email); Msg.Subject = ConfigurationManager.AppSettings["EmailSubject"]; Msg.Body = body; Msg.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Send(Msg); adminMsg.From = new MailAddress(ConfigurationManager.AppSettings["ContactEmail"]); adminMsg.To.Add(adminmail); adminMsg.Subject = ConfigurationManager.AppSettings["EmailSubject"]; adminMsg.Body = body; adminMsg.IsBodyHtml = true; SmtpClient adminsmtp = new SmtpClient(); adminsmtp.Send(adminMsg); int oredernote = helper.ExecuteNonQuery("insert into ordernote(Note,OrderID,CreatedDate) values('" + OrderNote + "','" + orderid + "','" + DateTime.Now.ToString() + "')"); if (oredernote > 0) { } int transaction = helper.ExecuteNonQuery("insert into ordertransaction (TransactionID,InvoiceNum,Amount,CardNumber,CardName,CardType,Status,PaymentDate,PaymentType) values('" + tid.InnerHtml + "','" + orderid + "','" + Amount.InnerHtml + "','" + cardnumber + "','" + cardname + "','" + cardtype + "','" + status + "','" + PaymentDt + "','" + PaymentType + "')"); if (transaction > 0) { } Email = email; // con.SendMail(Email, orderid, adminmail); Response.Redirect("OrderDetail.aspx?Id=" + OrderNo); } } } //int ordernote = helper.ExecuteNonQuery("insert into OrderNote(Note,OrderID,CreatedDate) values('" + txtnote.Text + "','" + orderid + "','" + DateTime.Now + "')"); //if (ordernote > 0) //{ //} //else //{ //} } } } } } } } } } //string PaymentBy = aParam[10]; //string UserID = aParam[20]; ////objOrder.SiteId = Convert.ToInt32(aParam[20]); //int PlanDetailID = Convert.ToInt32(aParam[21]); //if (objOrder.ActivePlan != 1) //{ // objOrder.AmountPaid = 0; // objOrder.ActivePlan = 0; //} //EventLogFields objevent = new EventLogFields(); //if (aParam[1] == "success") //{ // objevent.EventDetail = "Your payment for subscription has successfully done"; // objevent.EventName = "Payment Successful"; //} //else //{ // objevent.EventDetail = "Your payment for subscription has failed"; // objevent.EventName = "Payment Failed"; //} //objevent.ModuleType = 4; //objevent.ReferenceNo = objOrder.PlanDetailID.ToString(); //objevent.SiteId = 83; //objevent.UpdatedDetails = ""; //objevent.userid = objOrder.UserID; //objevent.UserType = 2; //string serializedModel = JsonConvert.SerializeObject(objOrder); //string serializedModel1 = JsonConvert.SerializeObject(objevent); //CommonFunctions.SavePaymentDetail(serializedModel); //CommonFunctions.EventLogEntry(serializedModel1); } else { Response.Redirect("ErrorHandling.aspx"); // Response.Write("Payment Fails! Order Pending to save"); } } } } catch (Exception ex) { string filepath = HttpContext.Current.Server.MapPath("~/logfile"); string Errormsg = ex.GetType().Name.ToString(); if (!Directory.Exists(filepath)) { Directory.CreateDirectory(filepath); } filepath = filepath + DateTime.Today.ToString("dd-MM-yy") + ".txt"; //Text File Name if (!File.Exists(filepath)) { File.Create(filepath).Dispose(); } using (StreamWriter sw = File.AppendText(filepath)) { string Exception = ex.ToString(); string error = ex.StackTrace.ToString() + "Error Message:" + Errormsg + "InnerExpectation" + Exception; sw.WriteLine(error); } //throw ex; } }
protected void Fillcart1() { try { if (Session["userID"] != null && Session["username"] != null) { decimal total = 0; Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_Addtocart_detailwithuserid(Session["userID"].ToString()); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { grdviewcart.DataSource = ds.Tables[0]; grdviewcart.DataBind(); for (int i = 0; i < grdviewcart.Rows.Count; i++) { DropDownList ddl = (DropDownList)grdviewcart.Rows[i].FindControl("ddllise"); Label lblPrice = (Label)grdviewcart.Rows[i].FindControl("lblPrice"); Label lblTotal = (Label)grdviewcart.Rows[i].FindControl("lbltotal"); // TextBox lblqty = (TextBox)grdviewcart.Rows[i].FindControl("txtqty"); HiddenField hdmaxqty = (HiddenField)grdviewcart.Rows[i].FindControl("hdnmaxqty"); HiddenField hdqty = (HiddenField)grdviewcart.Rows[i].FindControl("hdnqty"); HiddenField txtqty = (HiddenField)grdviewcart.Rows[i].FindControl("txtqty"); decimal qty = Convert.ToDecimal(txtqty.Value); txtqty.Value = qty.ToString("0.##"); if (hdmaxqty.Value != "") { decimal maxqty = Convert.ToDecimal(hdqty.Value); decimal multiplication = qty * maxqty; List <string> lst = new List <string>(); decimal da = 0; Dictionary <string, decimal> source = new Dictionary <string, decimal>(); for (decimal j = multiplication; j <= 100; j += multiplication) { da = j; lst.Add(da.ToString("0.##")); } ddl.DataSource = lst; ddl.DataBind(); string qt = Convert.ToDecimal(hdmaxqty.Value).ToString("0.##"); ddl.SelectedValue = qt; ddl.Visible = true; } else { ddl.Visible = false; } decimal subtotal1 = Convert.ToDecimal(lblPrice.Text) * Convert.ToDecimal(hdmaxqty.Value); total += subtotal1; lblTotal.Text = subtotal1.ToString("0.##"); lblsubtotal.Text = total.ToString("0.00"); lbltotal.Text = total.ToString("0.00"); } } else { btnUpdatecart.Visible = false; btncheckout.Visible = false; totals.Visible = false; grdviewcart.DataSource = null; grdviewcart.DataBind(); } } } else { Response.Redirect("User_Login.aspx"); } } catch (Exception ex) { throw ex; } }
public void getallproduct() { try { if (Request.QueryString["Id"] != null) { Config config = new Config(); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_Product_detail(Request.QueryString["Id"].ToString()); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { h1.Value = ds.Tables[0].Rows[0]["Product_id"].ToString(); rptdata.DataSource = ds.Tables[0]; rptdata.DataBind(); foreach (RepeaterItem i in rptdata.Items) { DropDownList ddl = (DropDownList)i.FindControl("ddllise"); HiddenField hdmaxqty = (HiddenField)i.FindControl("hdnmaxqty"); HiddenField hdproductid = (HiddenField)i.FindControl("h1"); HiddenField txtqty = (HiddenField)i.FindControl("txtqty"); Label lblmsg = (Label)i.FindControl("lblmsg"); LinkButton btn1 = (LinkButton)i.FindControl("btnaddtocart"); int qty = Convert.ToInt32(txtqty.Value); if (hdmaxqty.Value != "") { int maxqty = Convert.ToInt32(hdmaxqty.Value); int multiplication = qty * maxqty; List <string> lst = new List <string>(); int da = 0; Dictionary <string, int> source = new Dictionary <string, int>(); for (int j = multiplication; j <= 100; j += multiplication) { da = j; lst.Add(da.ToString()); } ddl.DataSource = lst; ddl.DataBind(); ddl.Visible = true; } else { ddl.Visible = false; } HiddenField hdnstock = (HiddenField)i.FindControl("hdnstock"); double hd = Convert.ToDouble(hdnstock.Value); if (hd != 0.00) { decimal stock = Convert.ToDecimal(hdnstock.Value); if (Convert.ToInt32(txtqty.Value) <= stock) { lblmsg.Text = "In Stock"; } else { btn1.Visible = false; lblmsg.Text = "Out Of Stock"; } } else { lblmsg.Text = "Stock is not Available"; } } } } } } catch (Exception ex) { throw ex; } }
protected void btnaddtocart_Click(object sender, EventArgs e) { try { DataHelper helper = new DataHelper(); if (Session["userID"] != null && Session["username"] != null) { foreach (RepeaterItem i in rptdata.Items) { Config config = new Config(); DropDownList ddlqty = (DropDownList)i.FindControl("ddllise"); Label txtExample = (Label)i.FindControl("lblprice"); HiddenField hdproductid = (HiddenField)i.FindControl("h1"); HiddenField txtqty = (HiddenField)i.FindControl("txtqty"); HiddenField hdnstock = (HiddenField)i.FindControl("hdnstock"); double hd = Convert.ToDouble(hdnstock.Value); if (hd != 0.00) { decimal stock = Convert.ToDecimal(hdnstock.Value); int customerid = Convert.ToInt32(Session["userID"]); System.Data.DataSet ds = new System.Data.DataSet(); ds.Reset(); ds = config.get_Addtocart_detail(Request.QueryString["Id"].ToString(), Session["userID"].ToString()); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { if (ddlqty.SelectedValue != "") { if (Convert.ToInt32(ddlqty.SelectedValue) > 0) { if (Convert.ToInt32(ddlqty.SelectedValue) <= stock) { int qty = Convert.ToInt32(ddlqty.SelectedValue); int maxqty = Convert.ToInt32(ds.Tables[0].Rows[0]["MaxQuantity"].ToString()); //decimal stock1 = stock - qty; decimal quantity1 = qty; int x = helper.ExecuteNonQuery("update AddToCart set MaxQuantity='" + quantity1 + "' where CartID='" + ds.Tables[0].Rows[0]["CartID"] + "'"); if (x > 0) { lblmessage.Text = "Product Successfully added in Cart"; // Response.Redirect("Productdetails.aspx?Id=" + Request.QueryString["Id"].ToString()); } } else { System.Data.DataSet ds1 = new System.Data.DataSet(); ds1.Reset(); ds1 = config.get_Addtocart_detailwithproductuserid(Request.QueryString["Id"].ToString(), Session["userID"].ToString()); if (ds1.Tables.Count > 0) { if (ds1.Tables[0].Rows.Count > 0) { decimal availablestock = Convert.ToDecimal(ds1.Tables[0].Rows[0]["AvailableStock"].ToString()); if (ds1.Tables[0].Rows[0]["AvailableStock"].ToString() == "") { lblmessage.Text = "The Maximum quantity allowed for purchase is "; } else { int availablestock1 = Convert.ToInt32(availablestock); lblmessage.Visible = true; lblmessage.Text = "The Maximum quantity allowed for purchase is " + availablestock1; } } } } } else { lblmessage.Text = "Enter Quantity greater than 0"; } } else { lblmessage.Text = "Enter Quantity greater than 0"; } } else { if (ddlqty.SelectedValue != "") { if ((Convert.ToInt32(ddlqty.SelectedValue) > 0)) { if (Convert.ToInt32(ddlqty.SelectedValue) <= stock) { int qty = Convert.ToInt32(txtqty.Value); // decimal maxqty = Convert.ToDecimal(ds.Tables[0].Rows[0]["MaxQuantity"].ToString()); //decimal stock1 = stock - qty; int x = helper.ExecuteNonQuery("insert into AddToCart (ProductID,CustomerID,Price,MinQuantity,MaxQuantity,Cart_Status,OrderID) values ('" + hdproductid.Value + "','" + customerid + "','" + txtExample.Text + "','" + txtqty.Value + "','" + ddlqty.SelectedValue + "','" + 0 + "','" + 0 + "')"); if (x > 0) { lblmessage.Text = "Product Successfully added in Cart"; } //int z = helper.ExecuteNonQuery("update products set AvailableStock='" + stock1 + "' where product_ID='" + hdproductid.Value + "'"); //if (z > 0) //{ //} } else { int availablestock1 = Convert.ToInt32(stock); lblmessage.Visible = true; lblmessage.Text = "The Maximum quantity allowed for purchase is " + availablestock1; } } else { lblmessage.Text = "Enter Quantity greater than 0"; } } else { lblmessage.Text = "Enter Quantity greater than 0"; } } } else { } } else { lblmessage.Text = "No stock available"; } } //ScriptManager.RegisterStartupScript(this, typeof(Page), "script", "setTimeout(function(){window.location.href='Productdetails.aspx?Id='" + Request.QueryString["Id"].ToString() + ";},1000);", true); //Response.Redirect("ProductDetails.aspx?Id=" + Request.QueryString["Id"].ToString()); var master = Master as Main_Master; if (master != null) { master.Fillcart(); master.fillCat(); } } else { Response.Redirect("User_Login.aspx"); } } catch (Exception ex) { throw ex; } }
public void GetUserOrderDetail() { try { if (Request.QueryString["UserID"] != null && Request.QueryString["OrderID"] != null) { System.Data.DataTable ds = new System.Data.DataTable(); ds.Reset(); ds = conf.GetAllOrderUserOrderWise(Request.QueryString["UserID"].ToString(), Request.QueryString["OrderID"].ToString()); if (ds.Rows.Count > 0) { if (ds.Rows.Count > 0) { lblCustomername.Text = ds.Rows[0]["CustomerName"].ToString(); lblorderDate.Text = ds.Rows[0]["OrderDate"].ToString(); lblemail.Text = ds.Rows[0]["EmailAddress"].ToString(); lblphone.Text = ds.Rows[0]["phonenumber"].ToString(); lbladdress.Text = ds.Rows[0]["Address1"].ToString(); // lblcountry.Text = ds.Rows[0]["Countryname"].ToString(); lblstate.Text = ds.Rows[0]["state"].ToString(); DateTime dt = Convert.ToDateTime(ds.Rows[0]["OrderDate"]); lblorderDate.Text = dt.ToString("dd/MM/yyyy"); lblorderno.Text = ds.Rows[0]["OrderNo"].ToString(); lblsubtotal.Text = ds.Rows[0]["OrderTotalAmount"].ToString(); lblTotal.Text = ds.Rows[0]["OrderTotalAmount"].ToString(); string ordernote = ds.Rows[0]["note"].ToString(); if (ordernote != "") { divnote.Visible = true; string note = ordernote.Replace("br /", Environment.NewLine); txtnote.Text = note; } else { divnote.Visible = false; } System.Data.DataTable ds1 = new System.Data.DataTable(); ds1 = conf.GetProductdetailwithorderid(Request.QueryString["OrderID"].ToString()); grduserorder.DataSource = ds1; grduserorder.DataBind(); for (int i = 0; i < grduserorder.Rows.Count; i++) { Label lblprice = (Label)grduserorder.Rows[i].FindControl("lblprice"); Label lblprototal = (Label)grduserorder.Rows[i].FindControl("lbltotal"); Label lblqty = (Label)grduserorder.Rows[i].FindControl("lblqty"); int qty = Convert.ToInt32(lblqty.Text); decimal subtotal = Convert.ToDecimal(lblprice.Text) * Convert.ToDecimal(lblqty.Text); lblqty.Text = qty.ToString(); lblprototal.Text = subtotal.ToString("0.00"); } } } System.Data.DataSet userdt = new System.Data.DataSet(); userdt.Reset(); userdt = conf.GetUserDetailByID(Request.QueryString["UserID"].ToString()); if (userdt.Tables[0].Rows.Count > 0) { lblvacode.Text = userdt.Tables[0].Rows[0]["VACode"].ToString(); lblvaname.Text = userdt.Tables[0].Rows[0]["Name"].ToString(); lblvaemail.Text = userdt.Tables[0].Rows[0]["EmailAddress"].ToString(); lblvaphone.Text = userdt.Tables[0].Rows[0]["MobileNo"].ToString(); lblvaaddress.Text = userdt.Tables[0].Rows[0]["Address1"].ToString(); } } else { Response.Redirect("User_Login.aspx"); } } catch (Exception ex) { throw ex; } }