Hitman™
Legendary Member

- Messages
- 12,283
- Joined
- Apr 27, 2010
- Messages
- 12,283
- Reaction score
- 163
- Points
- 128
Attachments
-
24.9 KB Views: 55
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.

dah attach ss..

thanks bro, boleh explain sket x apa yg berlaku kat form ni?
![]()
cuba betulkan aku kalu salah, nko akan add setiap purchase (betul ka ni?) & pastu calculate total purchase & print resit...tiap kali add data tersebut akan masuk dalam gridview & aku assume kotak putih kecik kat bawah sekali akan papar total price...apa fungsi kotak putih besar tu??:-?
Hitman™;15855346 said:yup betol.
kotak putih besar sebelah data grid view tue adalah list no product.
so bila aku pilih no product dlm kotak besar tue.
automaticly noprodut,supplier,size,price akan dipaparkan
kemudian aku letak number dalam quantity.
so price seunit akan dikali dengan quantity.
then tekan add, detail masuk dalam datagrid view
and tekan calculate dia akan kira total semua price.

yuppp, aku dah agak dah...so everytime nak add nko kena select product dari kotak putih tu dulu la ek??? jenuh nak scroll cari product camtu kalu ada 1000 jenis product code unless kalu mcm kat kaunter tu scan jer nnt auto detect product & just masukkan kuantiti jer pastu prot pret prot pret system kira sume zreeetttttt print resit...
idea aku untuk nko, kalu menda ni bukan untuk kaunter boleh cuba cara ni :
1) Mcm google nyer future, nko taip jer auto akan kuar list any value related keyword yg di taip, so senang cite camni :
![]()
2) Guna Parent-Child teknik, form tu ada add button untuk retreive no.product, price, supplier & size camni :
![]()
* cara kedua tu aku x pasti samada boleh buat kat windows apps cam nko, kena wat research & explore sket...
it okay..sebab produk aku memang sikit.
sebab tue aku guna macam tue je.
masalah sekarang ialah nak save detail dari form tue ke dalam database.

masa bila nko save data ke DB? after click Print button??? apa yg aku faham, bila nak save jer nnt akan go through gridview read row by row while each row akan tag ngan unique id/transaction id dlm DB....foreach setiap row kat gridview read it, tag it, save it, print resit & you're done... ~ cakap mcm senang jer)
)
)
)
* maybe akan ada dua table kot bagi aku :
1) table rekod pembelian setiap product ~ senang nak wat report ka kiraan stock balancing ka
2) table untuk rekod transaksi ~ senang nak wat report ka kiraan untung rugi ka
konsep nko pakai delimeter tu betul dah, bahasa VB buat aku konfius sket so x reti nak share coding camna nko boleh cuba...tapi base on previous error tu, sytax SQL untuk INSERT nko tu kalu run dlm SQL mode ok x?:-?
just my dua kupang lima duit
Hitman™;15858166 said:cmner?...aku pown dah pening sendiri.
hahaha..)
no..ada satu button lagi, iaitu save button
aku xletak lagi.
yang print tue lain.
btw yang dah terjual tue tak pe..aku xbuat inventori
aku buat transaksi je.
so yang penting skrg databse tuk transaksi.
betol yang kau ckp tue..macam aku dah bagi kan detail dlm database transaski aku.
sekarang aku pening mcmner coding untuk masukkan detail2 tue melalui form tue.
//prepare connection string pekejadah sume tu
//prepare query arahan insert ke DB
//bla bla bla
//Start baca setiap rows & save value ke DB
foreach (DataRow drRowPurchase in DGV2.Rows)
{
//transcID
dbColumn[1] = "Cust" + DateTime.Now;
//prodPrice
if (string.IsNullOrEmpty(drRowPurchase[3].ToString()))
dbColumn[3] = "0.00";
else
{
string strPrice = drRowPurchase[3].ToString();
Decimal decPrice = Decimal.Parse(strPrice .ToString());
drRowPurchase[3] = decPrice .ToString("#,##0.00");
dbColumn[3] = Convert.ToDouble(drRowPurchase[3]);
**
//save changes ke DB
**

jgn pening2, tu cuma idea/pandangan aku jer...nko fokus program nko, kalu rasa idea/pandangan org lain boleh membantu baru nko try...
let say untuk transaksi session customer A, transaction id untuk customer A ialah Cust16012013013050 iaitu auto generate masa klik button save melalui kombinasi string "Cust" + DateTime.Now contohnya...
untuk session customer A tu dia beli 3 barang & dah tentu gridview nko ada 3 rekod/row kan?
data pembelian setiap produk tu nko simpan masa klik button save tu jer...
bila nko klik button save tu system akan start save data setiap row ke DB, let say :
masa save tu value yang di simpan ialah :
ID - autoincrement dlm DB
transcID - value transaction ID untuk session customer A
prodCode - value product code
prodPrice - value product price per-item
buyQty - value quantity product yg di beli
butDateTime - value date time product di beli
contoh lebih kurang camni :
Code://prepare connection string pekejadah sume tu //prepare query arahan insert ke DB //bla bla bla //Start baca setiap rows & save value ke DB foreach (DataRow drRowPurchase in DGV2.Rows) { //transcID drRowPurchase [1] = "Cust" + DateTime.Now; //prodPrice if (string.IsNullOrEmpty(drRowPurchase [3].ToString())) drRowPurchase [3] = "0.00"; else { string strPrice = drRowPurchase [3].ToString(); Decimal decPrice = Decimal.Parse(strPrice .ToString()); drRowPurchase [3] = decPrice .ToString("#,##0.00"); drRowPurchase [3] = Convert.ToDouble(drRowPurchase [3]); ** //save changes ke DB **
*** sorry aku x bagi proper code untuk nko test, harap nko boleh nampak apa yg aku cuba sampaikan...
Hitman™;15859320 said:coding vb ke tue..nape aku nmpk cm pelik je.)
public void btnSave_Click(object sender, EventArgs e)
{
try
{
if (DGV2.Rows.Count != 0)
{
string totalquery = null;
string connString = "Connection string nko";
totalquery = @"SELECT * FROM [DatabaseAku].[dbo].[tbl_Transaction];";
OleDbConnection totalconn = new OleDbConnection(connString);
OleDbCommand totalcmd = new OleDbCommand(totalquery, totalconn);
OleDbDataAdapter totalda = new OleDbDataAdapter(totalcmd);
DataSet totalds = new DataSet();
totalda.Fill(totalds);
if (totalconn.State == ConnectionState.Closed)
totalconn.Open();
string connection = @"Server=11.11.11.1;user id=userID;password=userPassword;database=DatabaseAku";
SqlConnection myConnection = new SqlConnection(connection);
myConnection.Open();
foreach (DataRow myRow in DGV2.Rows)
{
string strQuery = @"INSERT INTO [DatabaseAku].[dbo].[tbl_Transaction] ([transcID], [prodCode], [prodPrice], [butQty], [buyDateTime])
Values (@v_transcID, @v_prodCode, @v_prodPrice, @v_butQty, @v_buyDateTime)";
SqlCommand myCommand;
myCommand = new SqlCommand(strQuery, myConnection);
myCommand.Parameters.Add(new SqlParameter("@v_transcID", "Cust" + DateTime.Now));
myCommand.Parameters.Add(new SqlParameter("@v_prodCode", myRow[1].ToString()));
myCommand.Parameters.Add(new SqlParameter("@v_prodPrice", myRow[2].ToString()));
myCommand.Parameters.Add(new SqlParameter("@v_butQty", myRow[3].ToString()));
myCommand.Parameters.Add(new SqlParameter("@v_buyDateTime", System.DateTime.Now));
myCommand.ExecuteNonQuery();
**
myConnection.Close();
totalda.Dispose();
totalconn.Close();
totalconn.Dispose();
**
**
catch (Exception ex)
{
Response.Write(ex.ToString() + "<BR>");
**
**