Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: class and object Pin
Abhinav S2-Oct-13 0:20
Abhinav S2-Oct-13 0:20 
AnswerRe: class and object Pin
BillWoodruff2-Oct-13 6:16
professionalBillWoodruff2-Oct-13 6:16 
Questiondatatable . help needed Pin
superselector1-Oct-13 18:56
superselector1-Oct-13 18:56 
AnswerRe: datatable . help needed Pin
Abhinav S1-Oct-13 21:09
Abhinav S1-Oct-13 21:09 
AnswerRe: datatable . help needed Pin
Andy_L_J1-Oct-13 22:20
Andy_L_J1-Oct-13 22:20 
QuestionExternal component has thrown an exception Pin
Member 102708251-Oct-13 18:13
Member 102708251-Oct-13 18:13 
AnswerRe: External component has thrown an exception Pin
Abhinav S1-Oct-13 20:44
Abhinav S1-Oct-13 20:44 
GeneralRe: External component has thrown an exception Pin
Member 102708252-Oct-13 0:38
Member 102708252-Oct-13 0:38 
PrintDocument printdocument1 = new PrintDocument();
String koneksidatabase = " Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\DatabaseMDB\\DBSALES.mdb";
public Form1()
{
InitializeComponent();
printDocument1.PrintPage += printDocument1_PrintPage;
private void button2_Click(object sender, EventArgs e)
{
if (TXTBAYAR.Text == "")
{
MessageBox.Show("Please insert Buy");
return;

}





for (int i = 0; i < dataGridView2.Rows.Count; i++)
{
OleDbConnection con = new OleDbConnection(koneksidatabase);
OleDbCommand cmd = new OleDbCommand("insert into Sales ([Kode],[Nama Barang],[Harga],[Quantity],[Satuan],[Subtotal]) values (@Column1,@Column2,@Column3,@Column4,@Column5,@Column6)", con);
cmd.Parameters.AddWithValue("@Kode", dataGridView2.Rows[i].Cells[0].Value);
cmd.Parameters.AddWithValue("@Column2", dataGridView2.Rows[i].Cells[1].Value);
cmd.Parameters.AddWithValue("@Column3", dataGridView2.Rows[i].Cells[2].Value);
cmd.Parameters.AddWithValue("@Column4", dataGridView2.Rows[i].Cells[3].Value);
cmd.Parameters.AddWithValue("@Column5", dataGridView2.Rows[i].Cells[4].Value);
cmd.Parameters.AddWithValue("@Column6", dataGridView2.Rows[i].Cells[5].Value);





OleDbConnection con1 = new OleDbConnection(koneksidatabase);
OleDbCommand cmd1 = new OleDbCommand("insert into DetailSales ([Kode],[Nama Barang],[Harga],[Quantity],[Satuan],[Subtotal],[Total],[Bayar],[Kembalian],[DateTime]) values (@Column1,@Column2,@Column3,@Column4,@Column5,@Column6,@Total,@Bayar,@Kembalian,@DateTime)", con);
cmd1.Parameters.AddWithValue("@Kode", dataGridView2.Rows[i].Cells[0].Value);
cmd1.Parameters.AddWithValue("@Column2", dataGridView2.Rows[i].Cells[1].Value);
cmd1.Parameters.AddWithValue("@Column3", dataGridView2.Rows[i].Cells[2].Value);
cmd1.Parameters.AddWithValue("@Column4", dataGridView2.Rows[i].Cells[3].Value);
cmd1.Parameters.AddWithValue("@Column5", dataGridView2.Rows[i].Cells[4].Value);
cmd1.Parameters.AddWithValue("@Column6", dataGridView2.Rows[i].Cells[5].Value);
cmd1.Parameters.AddWithValue("@Total", txttotal1.Text);
cmd1.Parameters.AddWithValue("@Bayar", TXTBAYAR.Text);
cmd1.Parameters.AddWithValue("@Kembalian", TXTKEMBALIAN.Text);
cmd1.Parameters.AddWithValue("@DateTime", labelJam.Text);




con1.Open();
con.Open();
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
con.Close();
con1.Close();

}
{
{



printDocument1.Print();this stetment erorr?
dataGridView2.Rows.Clear();
MessageBox.Show("TRANSACTION COMPLITE!", "Complite");

TXTBAYAR.Clear();
TXTTOTAL.Clear();
TXTKEMBALIAN.Clear();
}
}
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Font print10B = new Font("Lucida Console", 10, FontStyle.Bold);

Font print8B = new Font("Arial", 9, FontStyle.Regular);

Font print6B = new Font("Arial", 8, FontStyle.Regular);

e.Graphics.DrawString("" + labelSTORE.Text + "'", print6B, Brushes.Black, 69, 20);
//e.Graphics.DrawString("" + labeladdress.Text + "'", print6B, Brushes.Black, 25, 30);

e.Graphics.DrawString("--------------------------------------------------- ", new Font(dataGridView2.Font.FontFamily, 10, FontStyle.Regular), Brushes.Black, 10, 35);

e.Graphics.DrawString(" Kasir :" + labelKASIR.Text + "'", print6B, Brushes.Black, 2, 50);

e.Graphics.DrawString("" + DateTime.Now.ToString("MM/dd/yyyy" + "-HH:mm:ss") + "'", print6B, Brushes.Black, 130, 50);

e.Graphics.DrawString("----------------------------------------------------", new Font(dataGridView2.Font.FontFamily, 10, FontStyle.Regular), Brushes.Black, 10, 60);
//e.Graphics.DrawString(" kode| Nama Barang | Harga | qty ", print6B, Brushes.Black, 6, 70);
int height = 0;

int x = 10;

for (int i = 0; i < dataGridView2.Rows.Count; i++)
{
e.Graphics.DrawString(dataGridView2.Rows[i].Cells[0].Value.ToString(), print6B, Brushes.Black, x, 70 + height);

e.Graphics.DrawString(dataGridView2.Rows[i].Cells[1].Value.ToString(), print6B, Brushes.Black, x + 50, 70 + height);

e.Graphics.DrawString(dataGridView2.Rows[i].Cells[2].Value.ToString(), print6B, Brushes.Black, x + 120, 70 + height);



// e.Graphics.DrawString("Rp,", print6B, Brushes.Black, x + 113, 70 + height);

e.Graphics.DrawString(dataGridView2.Rows[i].Cells[3].Value.ToString(), print6B, Brushes.Black, x + 170, 70 + height);

// e.Graphics.DrawString("=", print6B, Brushes.Black, x + 192, 70 + height);

e.Graphics.DrawString(dataGridView2.Rows[i].Cells[4].Value.ToString(), print6B, Brushes.Black, x + 180, 70 + height);

e.Graphics.DrawString(dataGridView2.Rows[i].Cells[5].Value.ToString(), print6B, Brushes.Black, x + 230, 70 + height);
height += 20;
}
{

{

e.Graphics.DrawString("--------------------------------------------------------------------------", print6B, Brushes.Black, x + 0, 60 + height);

e.Graphics.DrawString("Total :Rp, " + txttotal1.Text + "'", print6B, Brushes.Black, x + 0, 70 + height);


e.Graphics.DrawString("Bayar :Rp, " + TXTBAYAR.Text + "'", print6B, Brushes.Black, x + 0, 80 + height);

//e.Graphics.DrawString("Discount :" + 0 + "'", print6B, Brushes.Black, x + 0, 90 + height);

e.Graphics.DrawString("Kembali :Rp, " + TXTKEMBALIAN.Text + "'", print6B, Brushes.Black, x + 0, 90 + height);

e.Graphics.DrawString("--------------------------------------------------------------------------", print6B, Brushes.Black, x + 0, 110 + height);


e.Graphics.DrawString("Barang yang sudah di beli tidak dapat", print6B, Brushes.Black, x + 15, 120 + height);
e.Graphics.DrawString(" di kembalikan ", print6B, Brushes.Black, x + 70, 130 + height);
e.Graphics.DrawString("***Terima kasih***", print8B, Brushes.Black, x + 55, 140 + height);
}
}
}
}
}
GeneralRe: External component has thrown an exception Pin
Dave Kreskowiak2-Oct-13 4:37
mveDave Kreskowiak2-Oct-13 4:37 
GeneralRe: External component has thrown an exception Pin
ramonminarro11-Mar-22 3:10
ramonminarro11-Mar-22 3:10 
GeneralRe: External component has thrown an exception Pin
Dave Kreskowiak11-Mar-22 3:46
mveDave Kreskowiak11-Mar-22 3:46 
QuestionC# assignment please help Pin
bmulgrew11-Oct-13 18:07
professionalbmulgrew11-Oct-13 18:07 
AnswerRe: C# assignment please help Pin
Abhinav S1-Oct-13 21:10
Abhinav S1-Oct-13 21:10 
AnswerRe: C# assignment please help Pin
OriginalGriff1-Oct-13 21:25
mveOriginalGriff1-Oct-13 21:25 
GeneralDestructors Pin
N8tiv1-Oct-13 15:34
N8tiv1-Oct-13 15:34 
GeneralRe: Destructors Pin
Richard Andrew x641-Oct-13 16:29
professionalRichard Andrew x641-Oct-13 16:29 
GeneralRe: Destructors Pin
N8tiv1-Oct-13 16:31
N8tiv1-Oct-13 16:31 
GeneralRe: Destructors Pin
Richard Andrew x641-Oct-13 17:09
professionalRichard Andrew x641-Oct-13 17:09 
GeneralRe: Destructors Pin
Dave Kreskowiak1-Oct-13 17:05
mveDave Kreskowiak1-Oct-13 17:05 
GeneralRe: Destructors Pin
Richard Andrew x641-Oct-13 17:08
professionalRichard Andrew x641-Oct-13 17:08 
GeneralRe: Destructors Pin
Keith Barrow1-Oct-13 22:45
professionalKeith Barrow1-Oct-13 22:45 
GeneralRe: Destructors Pin
N8tiv1-Oct-13 19:56
N8tiv1-Oct-13 19:56 
AnswerRe: Destructors Pin
Ron Beyer1-Oct-13 17:48
professionalRon Beyer1-Oct-13 17:48 
GeneralRe: Destructors Pin
jschell2-Oct-13 8:42
jschell2-Oct-13 8:42 
AnswerRe: Destructors Pin
Abhinav S1-Oct-13 21:12
Abhinav S1-Oct-13 21:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.