private void txcontraseña_KeyPress_1(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { try { using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); try { LoginSesion(cn); } catch (SqlException slq) { txcontraseña.Text = ""; MessageBox.Show(slq.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } StatusConection(cn); } } catch { MessageBox.Show("Error! Su contraseña y/o usuario son invalidos ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txcontraseña.Text = ""; } } }
private void ListUsers_Click(object sender, EventArgs e) { if (ListUsers.Items.Count <= 0) { DataTable dt = new DataTable(); using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); SqlCommand UserList = new SqlCommand(); UserList.Parameters.Clear(); UserList.Connection = cn; UserList.CommandText = "select Users.[User] from dbo.[Users] where [Activeted] = @Activeted"; UserList.Parameters.AddWithValue("@Activeted", true); SqlDataAdapter UserSDA = new SqlDataAdapter(UserList); if (UserSDA != null) { UserSDA.Fill(dt); } foreach (DataRow row in dt.Rows) { ListUsers.Items.Add(row[0].ToString()); } cn.Close(); } } }
private void ListOfUsers_Click(object sender, EventArgs e) { ProgressSyncNav.Visible = false; if (ListOfUsers.Items.Count <= 0) { DataTable dt = new DataTable(); using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); SqlCommand UserList = new SqlCommand(); UserList.Parameters.Clear(); UserList.Connection = cn; UserList.CommandText = "IF ((Select TOP 1 PermisseLevel from dbo.[Users] where users.PermisseLevel = 1) = (select PermisseLevel from dbo.[Users] where Users.[User] =@User)) select Users.[User] from dbo.[Users] ELSE select Users.[User] from dbo.[Users] where Users.Termina = (select Terminal from dbo.Terminals where Terminals.[Number] = @NoTerminal)"; UserList.Parameters.AddWithValue("@User", username); UserList.Parameters.AddWithValue("@NoTerminal", terminal); UserList.ExecuteNonQuery(); SqlDataReader sdr = UserList.ExecuteReader(); try { while (sdr.Read()) { ListOfUsers.Items.Add(sdr["User"].ToString()); } cn.Close(); } catch (SqlException sq) { MessageBox.Show(sq.Message.ToString()); } } } }
private void IniciarBoton_Click(object sender, EventArgs e) { try { using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); try { LoginSesion(cn); } catch (SqlException slq) { txcontraseña.Text = ""; MessageBox.Show(slq.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } StatusConection(cn); } } catch { MessageBox.Show("Error! Su contraseña y/o usuario son invalidos ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txcontraseña.Text = ""; } }
private void comboBox1_Click(object sender, EventArgs e) { if (Banks.Items.Count <= 0) { DataTable dt = new DataTable(); using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); SqlCommand UserList = new SqlCommand(); UserList.Parameters.Clear(); UserList.Connection = cn; UserList.CommandText = "Select Name from BankSAT"; UserList.ExecuteNonQuery(); SqlDataReader sdr = UserList.ExecuteReader(); try { while (sdr.Read()) { Banks.Items.Add(sdr["Name"].ToString()); } cn.Close(); } catch (SqlException sq) { MessageBox.Show(sq.Message.ToString()); } } } }
private void getcreditsales() { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { con.Open(); SqlCommand getcreditsales = new SqlCommand(); getcreditsales.Parameters.Clear(); getcreditsales.Connection = con; getcreditsales.CommandText = "select COALESCE (SUM([Total]),0) from CardsDetail where [NumTerm] = @Terminal and [UserReg] =@user and [DateReg]=@datework and [Credit] = @credit"; getcreditsales.Parameters.AddWithValue("@Terminal", terminal); getcreditsales.Parameters.AddWithValue("@user", user); getcreditsales.Parameters.AddWithValue("@datework", datework); getcreditsales.Parameters.AddWithValue("@credit", true); SqlDataAdapter sda = new SqlDataAdapter(getcreditsales); DataTable creditsalestable = new DataTable(); if (sda != null) { sda.Fill(creditsalestable); } foreach (DataRow row in creditsalestable.Rows) { totalcreditsales = Decimal.Parse(row[0].ToString()); } detalleCorte1.Credits.Text = totalcreditsales.ToString(); salesInDetail1.TotalTransfe.Text = totalcreditsales.ToString(); con.Close(); } }
private DataTable DataAccountsTerm(string terminalreg) { DataTable datatb = new DataTable(); using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { checkConection(con); SqlCommand selectAccounts = new SqlCommand(); selectAccounts.Parameters.Clear(); selectAccounts.Connection = con; con.Open(); selectAccounts.CommandText = "select [AccountNAV], [CashOutsAccount] from Terminals where [Terminal] = @idTerm"; selectAccounts.Parameters.AddWithValue("@idTerm", terminalreg); SqlDataAdapter dtcashout = new SqlDataAdapter(selectAccounts); if (dtcashout != null) { dtcashout.Fill(datatb); } con.Close(); checkConection(con); } return(datatb); }
public int aceptcashout(string userreg) { int idreg = 0; using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { string datetimeposting = DateTime.Now.ToString("MM/dd/yyyy"); CodeCashOut = terminal + user + datetimeposting; con.Open(); SqlCommand regcashout = new SqlCommand(); regcashout.Parameters.Clear(); regcashout.Connection = con; regcashout.CommandText = "insert into CashOut([Total],[Date],[Terminal],[Idreg],[CasingAsigned],[CodeCashOut], [SyncNAV]) values " + "(@TotalCashOut,@Datework,(select Terminal from Terminals where Number = @Terminal),(select ID from Users where [User]=@User), (select ID from Users where [User] = @UserAsigned),@CodeCashOut, @SyncNAV) SELECT SCOPE_IDENTITY()"; regcashout.Parameters.AddWithValue("@TotalCashOut", cashCountOut1.TotalCashOut.Text.ToString()); regcashout.Parameters.AddWithValue("@Datework", datework); regcashout.Parameters.AddWithValue("@Terminal", terminal); regcashout.Parameters.AddWithValue("@User", userreg); regcashout.Parameters.AddWithValue("@UserAsigned", user.ToString()); regcashout.Parameters.AddWithValue("@CodeCashOut", CodeCashOut); regcashout.Parameters.AddWithValue("@SyncNAV", false); idreg = Convert.ToInt32(regcashout.ExecuteScalar()); } if (idreg > 0) { string totalcashout = cashCountOut1.TotalCashOut.Text.ToString(); SendGeneralJournal(CodeCashOut, totalcashout, idreg); this.Close(); } return(idreg); //metroProgressSpinner1.Visible = ; }
private void comboBox1_Click(object sender, EventArgs e) { if (UserList.Items.Count <= 0) { DataTable dt = new DataTable(); using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); SqlCommand UserListcomnmand = new SqlCommand(); UserListcomnmand.Parameters.Clear(); UserListcomnmand.Connection = cn; UserListcomnmand.CommandText = "select [User],[Active] from dbo.[Users] where [User] <> @User"; UserListcomnmand.Parameters.AddWithValue("@User", user); SqlDataAdapter UserSDA = new SqlDataAdapter(UserListcomnmand); if (UserSDA != null) { UserSDA.Fill(dt); } foreach (DataRow row in dt.Rows) { UserList.Items.Add(row[0].ToString()); } cn.Close(); } } }
private void TerminalList_Click(object sender, EventArgs e) { ProgressSyncNav.Visible = false; if (TerminalList.Items.Count <= 0) { DataTable dtT = new DataTable(); using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); SqlCommand ListTerminals = new SqlCommand(); ListTerminals.Parameters.Clear(); ListTerminals.Connection = cn; ListTerminals.CommandText = "IF ((Select TOP 1 PermisseLevel from dbo.[Users] where users.PermisseLevel = 1) = (select PermisseLevel from dbo.[Users] where Users.[User] =@User)) select Number from Terminals ELSE select Supervisor from Terminals where Supervisor = (select ID from Users where [Name] = @User)"; ListTerminals.Parameters.AddWithValue("@User", username); ListTerminals.ExecuteNonQuery(); SqlDataReader sdr = ListTerminals.ExecuteReader(); try { while (sdr.Read()) { TerminalList.Items.Add(sdr["Number"].ToString()); } cn.Close(); } catch (SqlException sq) { MessageBox.Show(sq.Message.ToString()); } } } }
private void NoTerminal_Click(object sender, EventArgs e) { if (NoTerminal.Items.Count <= 0) { DataTable dt = new DataTable(); using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { cn.Open(); SqlCommand TermList = new SqlCommand(); TermList.Parameters.Clear(); TermList.Connection = cn; TermList.CommandText = "select [Terminal] from Terminals"; SqlDataAdapter UserSDA = new SqlDataAdapter(TermList); if (UserSDA != null) { UserSDA.Fill(dt); } foreach (DataRow row in dt.Rows) { NoTerminal.Items.Add(row[0].ToString()); } cn.Close(); } } }
private void UpdateDatacompany(DataCompany DC) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { con.Open(); SqlCommand command = new SqlCommand(); command.Parameters.Clear(); command.Connection = con; command.CommandText = ("Select TOP 1 [NameCompany] from Company where [no] <> 0"); string Exist = command.ExecuteScalar().ToString(); if (Exist == null) { command.Parameters.Clear(); command.CommandText = ("Insert into Company ([NameCompany],[Location],[RFC],[PCode],[City],[StateMex],[Email],[Phone]) values(@NameCompany,@Location,@RFC,@PCode,@City,@StateMex,@Email,@Phone)"); command.Parameters.AddWithValue("@NameCompany", DC.Name.ToString()); command.Parameters.AddWithValue("@Location", (DC.Address.ToString() + ", " + DC.Address_2.ToString())); command.Parameters.AddWithValue("@RFC", DC.VAT_Registration_No.ToString()); command.Parameters.AddWithValue("@PCode", DC.Post_Code.ToString()); command.Parameters.AddWithValue("@City", DC.City.ToString()); command.Parameters.AddWithValue("@StateMex", DC.County.ToString()); command.Parameters.AddWithValue("@Email", DC.E_Mail.ToString()); command.Parameters.AddWithValue("@Phone", DC.Phone_No.ToString()); command.ExecuteScalar(); MessageBox.Show("Datos Actualizados, La aplicación se reiniciara para tomar los cambios", "Actualización Correcta", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Exist != null) { DialogResult result; result = MessageBox.Show("Se modificaran los datos de la empresa en la base local" + System.Environment.NewLine + "¿Desea continuar?", "Registro Duplicado", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { command.Parameters.Clear(); command.CommandText = ("UPDATE Company set [NameCompany] = @NameCompany,[Location] = @Location,[RFC] = @RFC,[PCode] = @PCode,[City] = @City,[StateMex] = @StateMex,[Email] = @Email,[Phone] = @Phone where [no] > 0"); command.Parameters.AddWithValue("@NameCompany", DC.Name.ToString()); command.Parameters.AddWithValue("@Location", (DC.Address.ToString() + ", " + DC.Address_2.ToString())); command.Parameters.AddWithValue("@RFC", DC.VAT_Registration_No.ToString()); command.Parameters.AddWithValue("@PCode", DC.Post_Code.ToString()); command.Parameters.AddWithValue("@City", DC.City.ToString()); command.Parameters.AddWithValue("@StateMex", DC.County.ToString()); command.Parameters.AddWithValue("@Email", DC.E_Mail.ToString()); command.Parameters.AddWithValue("@Phone", DC.Phone_No.ToString()); try { command.ExecuteNonQuery(); MessageBox.Show("Datos Actualizados, La aplicación se reiniciara para tomar los cambios", "Actualización Correcta", MessageBoxButtons.OK, MessageBoxIcon.Information); updatecorrectcompany = true; } catch (SqlException sqle) { MessageBox.Show(sqle.Message); } } } con.Close(); } }
public void checkusr() { using (SqlConnection CN = ConexionSQL.Cadenaconexion("ATX_POS")) { LashcutCount(CN); Checkconnection(CN); } }
private void InsertCountingUP() { using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { try { cn.Open(); string datework = DateTime.Today.ToString("MM/dd/yyyy"); SqlCommand CashIn = new SqlCommand(); CashIn.Parameters.Clear(); CashIn.Connection = cn; CashIn.CommandText = "Insert into CountingUp (Code,TotalCounting,DateCounting,Teriminal,IDreg,[IdComment]) " + "values(@CodeControl," + "@TotalCash," + "@Datework," + "(select Terminal from Terminals where Number=@Terminal)," + "(Select ID from dbo.[Users] where [Users].[User]=@User),@IdComment) " + "SELECT SCOPE_IDENTITY()"; CashIn.Parameters.AddWithValue("@User", UserLabel.Text.ToString()); CashIn.Parameters.AddWithValue("@Terminal", TerminalLabel.Text.ToString()); CashIn.Parameters.AddWithValue("@Datework", datework); CashIn.Parameters.AddWithValue("@TotalCash", metroLabel4.Text.Remove(0, 1)); CashIn.Parameters.AddWithValue("@CodeControl", datework + UserLabel.Text.ToString() + TerminalLabel.Text.ToString()); CashIn.Parameters.AddWithValue("@IdComment", idcomment); int CashID = Convert.ToInt32(CashIn.ExecuteScalar()); if (CashID > 0) { SqlCommand SesionControl = new SqlCommand(); SesionControl.Parameters.Clear(); SesionControl.Connection = cn; SesionControl.CommandText = "Insert into LoginsControl (DateWork,Terminal,[User],InitCountingUp,[Cierreturno],[CierreCaja]) values (@Datework,@Terminal,@User,@InitCountingUp,@closeturn,@closebox)"; SesionControl.Parameters.AddWithValue("Datework", datework); SesionControl.Parameters.AddWithValue("@Terminal", TerminalLabel.Text.ToString()); SesionControl.Parameters.AddWithValue("@User", UserLabel.Text.ToString()); SesionControl.Parameters.AddWithValue("@InitCountingUp", 1); SesionControl.Parameters.AddWithValue("@closeturn", 0); SesionControl.Parameters.AddWithValue("@closebox", 0); SesionControl.ExecuteNonQuery(); SqlCommand updatecomment = new SqlCommand(); updatecomment.Parameters.Clear(); updatecomment.Connection = cn; updatecomment.CommandText = "Update Comments set [IdCountingUp] = @IdCounting, [UserReg] = @User, [RegTerminal] = @Terminal where [IdComment] = @Idcomment"; updatecomment.Parameters.AddWithValue("@Idcomment", idcomment); updatecomment.Parameters.AddWithValue("@IdCounting", CashID); updatecomment.Parameters.AddWithValue("@User", UserLabel.Text.ToString()); updatecomment.Parameters.AddWithValue("@Terminal", TerminalLabel.Text.ToString()); updatecomment.ExecuteNonQuery(); } } catch (SqlException sqlex) { MessageBox.Show(sqlex.ToString()); } cn.Close(); } }
private void CashOutManual_Load(object sender, EventArgs e) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { GetInitcash(con); GetSalescash(con); GetCashOut(con); TotalCashInBox(); checkConection(con); } }
public void GetTerminalDetail() { string datework = DateTime.Today.ToString("MM/dd/yyyy"); string timework = DateTime.Today.ToString("HH:mm:ss"); try { using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { //MetroFramework.MetroMessageBox.Show(this, "Bienviendo de Vuelta: " + UserLabel.Text, "Welcome Back", MessageBoxButtons.OK, MessageBoxIcon.Information); cn.Open(); SqlCommand comando = new SqlCommand(); comando.Parameters.Clear(); comando.CommandText = "Select TOP 1 COALESCE ([CashOnBox],0) " + "from Casing where TerminalAsig = @Number and DateReg = @datework order by [TimeCasing] Desc"; comando.Connection = cn; comando.Parameters.AddWithValue("@Number", TerminalLabel.Text.ToString()); comando.Parameters.AddWithValue("@datework", datework); int count = Convert.ToInt32(comando.ExecuteScalar()); if (count > 0) { SqlDataAdapter sdacount = new SqlDataAdapter(comando); DataTable sdacotb = new DataTable(); sdacount.Fill(sdacotb); decimal lastcasing = 0M; foreach (DataRow row in sdacotb.Rows) { lastcasing = decimal.Parse(row[0].ToString()); } /*comando.ExecuteNonQuery(); * DataSet ds2 = new DataSet(); * SqlDataAdapter da2 = new SqlDataAdapter(comando); * da2.Fill(ds2, "Casing"); * DataRow DR2; * DR2 = ds2.Tables["Casing"].Rows[0];*/ metroLabel5.Text = lastcasing.ToString("N2"); } else { MetroFramework.MetroMessageBox.Show(this, "No hubo corte de caja anterior registrado o el usuario no dejo dinero en Caja", "No hubo fondo en caja registrado", MessageBoxButtons.OK, MessageBoxIcon.Warning); metroLabel5.Text = "0.00"; } cn.Close(); } } catch (SqlException exsql) { MetroFramework.MetroMessageBox.Show(this, exsql.Message.ToString(), "SQL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void GetAllStatics() { using (SqlConnection CN = ConexionSQL.Cadenaconexion("ATX_POS")) { //LashcutCount(CN); TotalCountings(CN); TotalSalesCash(CN); Totalcreditsales(CN); TotalDebitSales(CN); TotalOutsTerm(CN); LashcutCount(CN); Checkconnection(CN); GetRealMoney(); } }
private void updateactivesesion(DataRow DR) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { SqlCommand updatesesionsqlc = new SqlCommand(); updatesesionsqlc.Parameters.Clear(); updatesesionsqlc.CommandText = "Update Users set [Active] = @Active where [User]=@User"; updatesesionsqlc.Parameters.AddWithValue("@Active", true); updatesesionsqlc.Parameters.AddWithValue("@User", DR["User"].ToString()); con.Open(); updatesesionsqlc.Connection = con; updatesesionsqlc.ExecuteNonQuery(); con.Close(); } }
private void UpdeteSalesHeader(DataGridViewRow rows) { using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { checkConection(cn); SqlCommand updatesales = new SqlCommand(); updatesales.Parameters.Clear(); cn.Open(); updatesales.CommandText = "Update Sales SET [SyncNav]=1 where [NoVenta] =@salesId"; updatesales.Parameters.AddWithValue("@salesId", rows.Cells[0].Value.ToString()); updatesales.Connection = cn; updatesales.ExecuteNonQuery(); checkConection(cn); } }
private void DisableUser(string usercombobox) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { con.Open(); SqlCommand disablecomand = new SqlCommand(); disablecomand.Parameters.Clear(); disablecomand.Connection = con; disablecomand.CommandText = "Update Users set [Activeted] = @activeted where [User] = @SelectUser"; disablecomand.Parameters.AddWithValue("@SelectUser", usercombobox); disablecomand.Parameters.AddWithValue("@activeted", false); disablecomand.ExecuteNonQuery(); con.Close(); } }
private void updatecashout(int idreg) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { checkConection(con); SqlCommand updateCashOut = new SqlCommand(); updateCashOut.Parameters.Clear(); updateCashOut.Connection = con; con.Open(); updateCashOut.CommandText = "Update CashOut set [SyncNAV] = @SyncNAV WHERE [OutId] = @idreg"; updateCashOut.Parameters.AddWithValue("@idreg", idreg); updateCashOut.Parameters.AddWithValue("@SyncNAV", true); updateCashOut.ExecuteNonQuery(); checkConection(con); } }
private void getcashouts() { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { //Salidas cambio getcashsalesout(con); //Retiros de efectivo getadmincashout(con); decimal countingup = decimal.Parse(detalleCorte1.Apertura.Text.ToString()); decimal TOTALEFECT = ((salestotallingall + countingup) - (totaloutschange + totalouts)); detalleCorte1.efectivo.Text = TOTALEFECT.ToString(); salesInDetail1.TotalMoney.Text = salestotallingall.ToString(); salesInDetail1.cashout.Text = totaloutschange.ToString(); } }
private bool InsertCasing() { bool correct = false; using (SqlConnection cn = ConexionSQL.Cadenaconexion("ATX_POS")) { string datework = DateTime.Today.ToString("MM/dd/yyyy"); cn.Open(); //Efectivo. SqlCommand InsertCasing = new SqlCommand(); InsertCasing.Parameters.Clear(); InsertCasing.Connection = cn; InsertCasing.CommandText = "Insert into Casing ([InitCash],[FinishCash],[DateReg],[UserReg],[TerminalAsig],[BillTotals],[TotalCredit],[TotalDebit],[TimeCasing],[FinishCashTurn],[Idreg],[CashOnBox]) " + "values (@InitCash,@FinishCash,@Datework,@UserReg,@Terminal,@BillsTotal,@TotalCredit,@TotalDebit,@TimeCasing,@FinishCashturn,(select [ID] from Users where [User] = @UserReg),@cashOnbox) SELECT SCOPE_IDENTITY()"; InsertCasing.Parameters.AddWithValue("@InitCash", detalleCorte1.Apertura.Text.ToString()); //saldo final en caja InsertCasing.Parameters.AddWithValue("@FinishCash", totalSystem); InsertCasing.Parameters.AddWithValue("@Datework", datework); InsertCasing.Parameters.AddWithValue("@UserReg", user); InsertCasing.Parameters.AddWithValue("@Terminal", terminal); InsertCasing.Parameters.AddWithValue("@BillsTotal", detalleCorte1.Bills.Text.ToString()); InsertCasing.Parameters.AddWithValue("@TotalCredit", detalleCorte1.Credits.Text.ToString()); InsertCasing.Parameters.AddWithValue("@TotalDebit", detalleCorte1.Debits.Text.ToString()); string hour = DateTime.Now.ToString("HH:mm:ss"); InsertCasing.Parameters.AddWithValue("@TimeCasing", hour); GetTotalCashturn(); InsertCasing.Parameters.AddWithValue("@FinishCashturn", totalcashbox); InsertCasing.Parameters.AddWithValue("@cashOnbox", cashuserbox.Text.ToString()); int idcorte = Convert.ToInt32(InsertCasing.ExecuteScalar()); correct = true; if (idcorte > 0) { SqlCommand insertcontroluser = new SqlCommand(); insertcontroluser.Parameters.Clear(); insertcontroluser.Connection = cn; insertcontroluser.CommandText = ""; insertcontroluser.Parameters.AddWithValue("", ""); } cn.Close(); } return(correct); }
private void UpdatePaymentSales(DataGridViewRow rows) { using (SqlConnection cone = ConexionSQL.Cadenaconexion("ATX_POS")) { checkConection(cone); SqlCommand UpdatePaymentSales = new SqlCommand(); UpdatePaymentSales.Parameters.Clear(); //0[NoVenta], 1[Terminal], 2[SalesTotal], 3[CashPay], 4[NoTicket], 5[CorteReg] UpdatePaymentSales.CommandText = "update Sales set CorteReg = @PostJournalState where NoVenta = @NoVenta"; UpdatePaymentSales.Parameters.AddWithValue("@PostJournalState", true); UpdatePaymentSales.Parameters.AddWithValue("@NoVenta", rows.Cells[0].Value.ToString()); UpdatePaymentSales.Connection = cone; cone.Open(); UpdatePaymentSales.ExecuteNonQuery(); checkConection(cone); } }
private void UpdateSucData(string sucCode) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { con.Open(); SqlCommand UpdateSucs = new SqlCommand(); UpdateSucs.Parameters.Clear(); UpdateSucs.Connection = con; UpdateSucs.CommandText = ("Select TOP 1 [CodeStore] from StoresDetail where [No] <> 0"); string Exist = UpdateSucs.ExecuteScalar().ToString(); if (Exist == null) { UpdateSucs.Parameters.Clear(); UpdateSucs.CommandText = "insert into StoresDetail([CodeStore],[NameStore],[ManagerID],[Location],[Tel],[email],[statemex],[city]) values(@CodeStore, @NameStore, @ManageId, @Address, @Phone,@email,@state,@City)"; //@CodeStore, @NameStore, @ManageId, @Address, @Phone,@email,@state,@City UpdateSucs.Parameters.AddWithValue("@CodeStore", sucCode); UpdateSucs.Parameters.AddWithValue("@NameStore", NameSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@Address", AdressSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@Phone", PhoneSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@email", EmailSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@state", StateSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@City", CitySuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@ManageId", 1); UpdateSucs.ExecuteNonQuery(); } else if (Exist != null) { DialogResult result; result = MessageBox.Show("¿Desea Actualizar los datos de la Sucursal?", "Actulizar datos Sucursal", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { UpdateSucs.CommandText = "Update StoresDetail set [CodeStore] = @CodeStore, [NameStore] = @NameStore, [Location] = @Address, [Tel] = @Phone, [email] = @email, [statemex] = @state, [city] = @City where [no] <> 0"; UpdateSucs.Parameters.AddWithValue("@CodeStore", sucCode); UpdateSucs.Parameters.AddWithValue("@NameStore", NameSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@Address", AdressSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@Phone", PhoneSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@email", EmailSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@state", StateSuc.Text.ToString()); UpdateSucs.Parameters.AddWithValue("@City", CitySuc.Text.ToString()); UpdateSucs.ExecuteNonQuery(); } } con.Close(); } }
private void Aceptar_Click(object sender, EventArgs e) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { con.Open(); SqlCommand selectpermission = new SqlCommand(); selectpermission.Parameters.Clear(); selectpermission.Connection = con; selectpermission.CommandText = "select [PermisseLevel], [User] from Users where [User]=@user and [Password]=@password"; selectpermission.Parameters.AddWithValue("@user", txtusuario.Text.ToString()); selectpermission.Parameters.AddWithValue("@password", txcontraseña.Text.ToString()); SqlDataAdapter sda = new SqlDataAdapter(selectpermission); DataTable users = new DataTable(); if (sda != null) { sda.Fill(users); } foreach (DataRow rowuser in users.Rows) { level = rowuser[0].ToString(); user = rowuser[1].ToString(); //terminal = rowuser[2].ToString(); //password = rowuser[3].ToString(); } if ((level == "1") || (level == "2")) { cashout cashoutinterface = this.Owner as cashout; if (cashoutinterface != null) { idcashout = cashoutinterface.aceptcashout(txtusuario.Text.ToString()); if (idcashout > 0) { MessaComments(); } } } else { MetroFramework.MetroMessageBox.Show(this, "El usuario: " + txtusuario.Text.ToString() + " no tiene el nivel de privilegios requeridos para el retiro de efectivo en caja", "Usuario sin Privilegios", MessageBoxButtons.OK, MessageBoxIcon.Error); txcontraseña.Text = ""; txcontraseña.Focus(); } } }
private void GetAccountTerminal(ref string AccountTermNav, ref string CodeSuc, DataGridViewRow rowsal) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { //0"NoVenta", 1"Fecha Registro", 2"NoTicket", 3"SalesTotal", 4"CorteReg", 5"Number", 6"SyncNav" checkConection(con); SqlCommand checkaccount = new SqlCommand(); checkaccount.Parameters.Clear(); checkaccount.CommandText = "select [AccountNAV] from Terminals where [Number] = @Terminal"; checkaccount.Connection = con; con.Open(); checkaccount.Parameters.AddWithValue("@Terminal", rowsal.Cells[4].Value.ToString()); SqlDataAdapter AccountNumber = new SqlDataAdapter(checkaccount); DataTable AccountTable = new DataTable(); if (AccountNumber != null) { AccountNumber.Fill(AccountTable); } foreach (DataRow row in AccountTable.Rows) { AccountTermNav = row[0].ToString(); } checkConection(con); SqlCommand GetStoreCode = new SqlCommand(); GetStoreCode.Parameters.Clear(); GetStoreCode.CommandText = "select [AccountNAV] from Terminals where [Number] = @Terminal"; GetStoreCode.Connection = con; con.Open(); GetStoreCode.Parameters.AddWithValue("@Terminal", rowsal.Cells[4].Value.ToString()); SqlDataAdapter StoreCodeSDA = new SqlDataAdapter(GetStoreCode); DataTable StoreDaT = new DataTable(); if (StoreCodeSDA != null) { StoreCodeSDA.Fill(StoreDaT); } foreach (DataRow row in StoreDaT.Rows) { CodeSuc = row[0].ToString(); } checkConection(con); } }
private void UpdateActiveStatus() { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { con.Open(); SqlCommand comandUpdate = new SqlCommand(); comandUpdate.Parameters.Clear(); comandUpdate.Connection = con; comandUpdate.CommandText = "Update Users set [Active] = @Inactive where [User] = @User"; comandUpdate.Parameters.AddWithValue("@Inactive", false); comandUpdate.Parameters.AddWithValue("@User", UserList.SelectedItem.ToString()); comandUpdate.ExecuteNonQuery(); con.Close(); } Status.Text = "None"; Status.Style = MetroFramework.MetroColorStyle.Blue; UserList.Items.Clear(); UserList.Text = ""; Updatestatus.Enabled = false; }
private void closeturn() { using (SqlConnection cone = ConexionSQL.Cadenaconexion("ATX_POS")) { SqlCommand updatecontrolsesion = new SqlCommand(); updatecontrolsesion.Parameters.Clear(); cone.Open(); updatecontrolsesion.Connection = cone; updatecontrolsesion.CommandText = "Update LoginsControl set [Cierreturno] = @cierre where [DateWork] = @datework and [User]= @user"; updatecontrolsesion.Parameters.AddWithValue("@datework", datework); updatecontrolsesion.Parameters.AddWithValue("@user", user); updatecontrolsesion.Parameters.AddWithValue("@cierre", true); updatecontrolsesion.ExecuteNonQuery(); DialogResult re = MetroFramework.MetroMessageBox.Show(this, "El cierre de turno se ha registrado correctamente, la aplicación se cerrara a continuación", "Cierre de turno", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (re == DialogResult.OK) { Application.Exit(); } } }
private void GetAccountTerminal(ref string AccountTermNav, ref string CodeSuc) { using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS")) { checkConection(con); SqlCommand checkaccount = new SqlCommand(); checkaccount.Parameters.Clear(); checkaccount.CommandText = "select [AccountNAV] from Terminals where [Number] = @Terminal"; checkaccount.Connection = con; con.Open(); checkaccount.Parameters.AddWithValue("@Terminal", terminal); SqlDataAdapter AccountNumber = new SqlDataAdapter(checkaccount); DataTable AccountTable = new DataTable(); if (AccountNumber != null) { AccountNumber.Fill(AccountTable); } foreach (DataRow row in AccountTable.Rows) { AccountTermNav = row[0].ToString(); } checkConection(con); SqlCommand GetStoreCode = new SqlCommand(); GetStoreCode.Parameters.Clear(); GetStoreCode.CommandText = "select [AccountNAV] from Terminals where [Number] = @Terminal"; GetStoreCode.Connection = con; con.Open(); GetStoreCode.Parameters.AddWithValue("@Terminal", terminal); SqlDataAdapter StoreCodeSDA = new SqlDataAdapter(GetStoreCode); DataTable StoreDaT = new DataTable(); if (StoreCodeSDA != null) { StoreCodeSDA.Fill(StoreDaT); } foreach (DataRow row in StoreDaT.Rows) { CodeSuc = row[0].ToString(); } checkConection(con); } }