144 lines
4.9 KiB
C#
144 lines
4.9 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 itemUnit = "EA";
|
|
public string itemSupply = string.Empty;
|
|
public int itemSupplyidx = -1;
|
|
|
|
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)
|
|
{
|
|
var drv = bs.Current as DataRowView;
|
|
if (drv == null)
|
|
{
|
|
itemName = string.Empty;
|
|
item = -1;
|
|
itemmodel = string.Empty;
|
|
itemprice = 0;
|
|
itemSupply = string.Empty;
|
|
itemSupplyidx = -1;
|
|
itemUnit = "EA";
|
|
SID = string.Empty;
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
var dr = drv.Row as dsMSSQL.ItemsRow;
|
|
item = dr.idx;
|
|
if (dr.IsnameNull()) itemName = string.Empty;
|
|
else itemName = dr.name;
|
|
if (dr.IsmodelNull()) itemmodel = string.Empty;
|
|
else itemmodel = dr.model;
|
|
if (dr.IspriceNull()) itemprice = 0;
|
|
else itemprice = dr.price;
|
|
if (dr.IssupplyNull()) itemSupply = string.Empty;
|
|
else itemSupply = dr.supply;
|
|
if (dr.IssupplyidxNull()) itemSupplyidx = -1;
|
|
else itemSupplyidx = dr.supplyidx;
|
|
if (dr.IsunitNull()) itemUnit = "EA";
|
|
else itemUnit = dr.unit;
|
|
SID = dr.sid;
|
|
}
|
|
|
|
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)
|
|
{
|
|
var drv = this.bs.Current as DataRowView;
|
|
var img = this.pictureBox1.Image;
|
|
if (drv == null)
|
|
{
|
|
this.pictureBox1.Image = null;
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
var dr = drv.Row as dsMSSQL.ItemsRow;
|
|
var img1 = FCOMMON.DBM.GetImageData("Items", "image", dr.idx);
|
|
if (img1 != null) this.pictureBox1.Image = img1;
|
|
else this.pictureBox1.Image = null;
|
|
}catch (Exception ex)
|
|
{
|
|
this.pictureBox1.Image = null;
|
|
}
|
|
|
|
}
|
|
if (img != null) img.Dispose();
|
|
}
|
|
|
|
private void dv_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
|
|
btOK.PerformClick();
|
|
}
|
|
|
|
}
|
|
|
|
private void dv_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
btOK.PerformClick();
|
|
}
|
|
|
|
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
{
|
|
var drv = this.bs.Current as DataRowView;
|
|
if (drv == null) return;
|
|
var dr = drv.Row as dsMSSQL.ItemsRow;
|
|
if (dr.RowState == DataRowState.Deleted || dr.RowState == DataRowState.Detached ||
|
|
dr.RowState == DataRowState.Added)
|
|
{
|
|
FCOMMON.Util.MsgE("이미지는 등록 완료된 아이템만 가능합니다. 먼저 저장한 후 다시 시도하세요.");
|
|
return;
|
|
}
|
|
OpenFileDialog od = new OpenFileDialog();
|
|
if (od.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
|
|
var image = Image.FromFile(od.FileName);
|
|
if (!FCOMMON.DBM.setImageData(image, "Items", "image", dr.idx))
|
|
{
|
|
FCOMMON.Util.MsgE("등록 실패");
|
|
}
|
|
else
|
|
{
|
|
this.pictureBox1.Image = Image.FromFile(od.FileName);
|
|
}
|
|
}
|
|
}
|
|
}
|