Lite
How do I use Lite
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: LoadbalancingPeer.cs
Copy
433 public virtual bool OpChangeGroups(byte[] groupsToRemove, byte[] groupsToAdd)
434 {
435 if (this.DebugOut >= DebugLevel.ALL)
436 {
437 this.Listener.DebugReturn(DebugLevel.ALL, "OpChangeGroups()");
438 }
439
440 Dictionary
441 if (groupsToRemove != null)
442 {
443 opParameters[(byte)LiteOpKey.Remove] = groupsToRemove;
444 }
445 if (groupsToAdd != null)
446 {
447 opParameters[(byte)LiteOpKey.Add] = groupsToAdd;
448 }
449
450 return this.OpCustom((byte)LiteOpCode.ChangeGroups, opParameters, true, 0);
451 }
File name: LoadbalancingPeer.cs
Copy
463 public virtual bool OpRaiseEvent(byte eventCode, object customEventContent, bool sendReliable, RaiseEventOptions raiseEventOptions)
464 {
465 opParameters.Clear(); // re-used private variable to avoid many new Dictionary() calls (garbage collection)
466 opParameters[(byte)LiteOpKey.Code] = (byte)eventCode;
467 if (customEventContent != null)
468 {
469 opParameters[(byte) LiteOpKey.Data] = customEventContent;
470 }
471
472 if (raiseEventOptions == null)
473 {
474 raiseEventOptions = RaiseEventOptions.Default;
475 }
476 else
477 {
478 if (raiseEventOptions.CachingOption != EventCaching.DoNotCache)
479 {
480 opParameters[(byte) LiteOpKey.Cache] = (byte) raiseEventOptions.CachingOption;
481 }
482 if (raiseEventOptions.Receivers != ReceiverGroup.Others)
483 {
484 opParameters[(byte) LiteOpKey.ReceiverGroup] = (byte) raiseEventOptions.Receivers;
485 }
486 if (raiseEventOptions.InterestGroup != 0)
487 {
488 opParameters[(byte) LiteOpKey.Group] = (byte) raiseEventOptions.InterestGroup;
489 }
490 if (raiseEventOptions.TargetActors != null)
491 {
492 opParameters[(byte) LiteOpKey.ActorList] = raiseEventOptions.TargetActors;
493 }
494 if (raiseEventOptions.ForwardToWebhook)
495 {
496 opParameters[(byte) ParameterCode.EventForward] = true; //TURNBASED
497 }
498 }
499
500 return this.OpCustom((byte)LiteOpCode.RaiseEvent, opParameters, sendReliable, raiseEventOptions.SequenceChannel, raiseEventOptions.Encrypt);
501 }
File name: frmItems.cs
Copy
32 public void navigate_records(int inc)
33 {
34 config.singleResult("SELECT * FROM `tblitems`");
35 txtitemid.Text =config.dt.Rows[inc].Field
36 txtname.Text = config.dt.Rows[inc].Field
37 txtdescription.Text = config.dt.Rows[inc].Field
38 txtprice.Text = config.dt.Rows[inc].Field
39 cbotype.Text = config.dt.Rows[inc].Field
40 //txtqty.Text = config.dt.Rows[inc].Field
41 //cbounit.Text = config.dt.Rows[inc].Field
42
43
44 }
File name: frmItems.cs
Copy
45 private void btnnew_Click(object sender, EventArgs e)
46 {
47
48 inc = 0;
49
50 sql = "SELECT * FROM tblitems";
51 config.Load_DTG(sql, dtglist);
52
53 maxcolumn = dtglist.Columns.Count - 1;
54
55 dtglist.Columns[maxcolumn].Visible = false;
56
57 btnadd.Visible = false;
58
59 select_navigation("SELECT ITEMID FROM tblitems");
60 lblmax.Text = maxrow.ToString();
61 lblinc.Text = inc.ToString();
62
63 sql = "SELECT DESCRIPTION FROM `tblsettings` WHERE `PARA`='CATEGORY'";
64 config.fiil_CBO(sql, cbotype);
65
66 sql = "SELECT DESCRIPTION FROM `tblsettings` WHERE `PARA`='Unit'";
67 config.fiil_CBO(sql, cbounit);
68
69
70 funct.clearTxt(pnl_stockmaster);
71
72 }
File name: frmItems.cs
Copy
86 private void btnsave_Click(object sender, EventArgs e)
87 {
88
89 foreach(Control obj in pnl_stockmaster.Controls)
90 {
91 if(obj is TextBox)
92 {
93 if(obj.Text == "")
94 {
95 MessageBox.Show("Action connot be perform. All fields are required to be fill up.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
96 return;
97 }
98 }
99 }
100
101
102
103 sql = "INSERT INTO `tblstock_in_out` (`ITEMID`, `QTY`,`TRANSACTIONDATE`, `TOTALPRICE`, `REMARKS`)" +
104 " VALUES ('" + txtitemid.Text + "','" + txtqty.Text + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + txtprice.Text +
105 "','StockIn')";
106 config.Execute_Query(sql);
107
108
109 sql = "SELECT ITEMID FROM tblitems WHERE ITEMID='" + txtitemid.Text + "'";
110 config.singleResult(sql);
111 if(config.dt.Rows.Count > 0)
112 {
113 sql = "UPDATE tblitems SET qty =qty + '" + txtqty.Text + "' WHERE ITEMID ='" + txtitemid.Text + "'";
114 config.Execute_Query(sql);
115 }
116 else
117 {
118 sql = "insert into tblitems (ITEMID,`NAME`, `DESCRIPTION`, `TYPE`, `PRICE`, `QTY`,UNIT)" +
119 "VALUES ('" + txtitemid.Text + "','" + txtname.Text + "','" + txtdescription.Text + "','" + cbotype.Text
120 + "','" + txtprice.Text + "','" + txtqty.Text + "','" + cbounit.Text + "' )";
121 config.Execute_CUD(sql, "No data saved.", "Data has been saved in the database.");
122
123 config.update_Autonumber(cbotype.Text);
124 }
125
126 btnnew_Click(sender, e);
127
128 }
File name: frmItems.cs
Copy
130 private void btnupdate_Click(object sender, EventArgs e)
131 {
132 sql = "UPDATE tblitems SET `NAME`='" + txtname.Text + "', `DESCRIPTION`='" + txtdescription.Text + "', `TYPE`='" + cbotype.Text + "', `PRICE`='" + txtprice.Text + "'" +
133 ",`UNIT`='" + cbounit.Text + "' WHERE ITEMID='" + txtitemid.Text + "'";
134 config.Execute_CUD(sql, "Error to update", "Data has been updated in the database");
135 btnnew_Click(sender, e);
136 }
File name: frmItems.cs
Copy
138 private void btndelete_Click(object sender, EventArgs e)
139 {
140 sql = "DELETE FROM tblitems WHERE ITEMID='" + dtglist.CurrentRow.Cells[0].Value + "'";
141 config.Execute_CUD(sql, "error to delete", "Data has been deleted.");
142 btnnew_Click(sender, e);
143 }
File name: frmItems.cs
Copy
156 private void dtglist_Click(object sender, EventArgs e)
157 {
158 sql = "SELECT * FROM tblitems WHERE ITEMID='" + dtglist.CurrentRow.Cells[0].Value.ToString() + "'";
159 config.singleResult(sql);
160 if (config.dt.Rows.Count > 0)
161 {
162 txtitemid.Text = config.dt.Rows[0].Field
163 txtname.Text = config.dt.Rows[0].Field
164 txtdescription.Text = config.dt.Rows[0].Field
165 txtprice.Text = config.dt.Rows[0].Field
166 cbotype.Text = config.dt.Rows[0].Field
167 //txtqty.Text = config.dt.Rows[0].Field
168 //cbounit.Text = config.dt.Rows[0].Field
169 }
170 }
File name: frmItems.cs
Copy
180 private void btnlast_Click(object sender, EventArgs e)
181 {
182 select_navigation("SELECT ITEMID FROM tblitems");
183 if(inc!= maxrow)
184 {
185 inc = maxrow;
186 lblinc.Text = inc.ToString();
187 inc = maxrow - 1;
188 navigate_records(inc);
189 }
190 }
File name: frmItems.cs
Copy
215 private void btnnext_Click(object sender, EventArgs e)
216 {
217 int lbl_inc;
218
219 select_navigation("SELECT ITEMID FROM tblitems");
220 if(inc==maxrow-1)
221 {
222 MessageBox.Show("no more rows", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
223 }
224 else
225 {
226 if (inc != maxrow - 1)
227 {
228 inc = inc + 1;
229 navigate_records(inc);
230 }
231
232 lbl_inc = int.Parse(lblinc.Text) + 1;
233 lblinc.Text = lbl_inc.ToString();
234 }
235 }
Lite 140 lượt xem
Gõ tìm kiếm nhanh...