82 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Windows.Forms;
 | |
| 
 | |
| namespace FCM0000
 | |
| {
 | |
|     public partial class fLovItem : Form
 | |
|     {
 | |
|         public string itemName = string.Empty;
 | |
|         public int item = -1;
 | |
|         public string itemmodel = string.Empty;
 | |
|         public decimal itemprice = 0;
 | |
|         public string SID = string.Empty;
 | |
|         public string itemSupply = string.Empty;
 | |
| 
 | |
|         string keyword = string.Empty;
 | |
|         public fLovItem(string search_)
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             this.keyword = search_;
 | |
|             this.KeyPreview = true;
 | |
|             this.KeyDown += (s1, e1) => {
 | |
|                 if (e1.KeyCode == Keys.Escape) this.Close();
 | |
|             };
 | |
|             
 | |
|         }
 | |
| 
 | |
|         private void fLovItem_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             //search data
 | |
|             this.ta.FillSearch(this.dsMSSQL.Items,this.keyword);
 | |
|         }
 | |
| 
 | |
|         private void itemsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (itemName.isEmpty() || item == -1) DialogResult = System.Windows.Forms.DialogResult.Cancel;
 | |
|             else DialogResult = System.Windows.Forms.DialogResult.OK;
 | |
|         }
 | |
| 
 | |
|      
 | |
|         private void bs_CurrentChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             
 | |
|         }
 | |
| 
 | |
|         private void dv_KeyDown(object sender, KeyEventArgs e)
 | |
|         {
 | |
|             if (e.KeyCode == Keys.Enter)
 | |
|             {
 | |
|                 var drv = bs.Current as DataRowView;
 | |
|                 if (drv == null)
 | |
|                 {
 | |
|                     itemName = string.Empty;
 | |
|                     item = -1;
 | |
|                     itemmodel = string.Empty;
 | |
|                     itemprice = 0;
 | |
|                     itemSupply = string.Empty;
 | |
|                     SID = string.Empty;
 | |
|                     return;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     var dr = drv.Row as dsMSSQL.ItemsRow;
 | |
|                     item = dr.idx;
 | |
|                     itemName = dr.name;
 | |
|                     itemmodel = dr.model;
 | |
|                     itemprice = dr.price;
 | |
|                     itemSupply = dr.supply;
 | |
|                     SID = dr.sid;
 | |
|                 }
 | |
|                 btOK.PerformClick();
 | |
|             }
 | |
|                 
 | |
|         }
 | |
|     }
 | |
| }
 | 
