190806 chi 품목정보에서 카테고리 없는 자료도 보이게 함

품목정보 정렬 기능 추가
190731  로그기록화면(beta)추가
This commit is contained in:
chikyun.kim
2019-08-06 11:38:05 +09:00
parent 11d7c7f704
commit 63dffe62ef
95 changed files with 21458 additions and 845 deletions

View File

@@ -72,12 +72,12 @@ namespace FCOMMON
}
public static Boolean setImageData(System.Drawing.Image img, string table, string field, int idx)
{
if (img == null || img.Width < 1||img.Height < 1) return false;
if (img == null || img.Width < 1 || img.Height < 1) return false;
//이미지가 640보다 크면 조정한다.
if(img.Width > 640)
if (img.Width > 640)
{
var newrate = (640.0 / img.Width * 1.0);
var newrate = (640.0 / img.Width * 1.0);
var newheight = (int)(img.Height * newrate); //높이값 다시 계산
var newimg = new System.Drawing.Bitmap(640, newheight);
var g = System.Drawing.Graphics.FromImage(newimg);
@@ -85,13 +85,14 @@ namespace FCOMMON
g.Dispose();
img = (System.Drawing.Image)(newimg.Clone());
} else if(img.Height > 480)
}
else if (img.Height > 480)
{
var newrate = (480.0 / img.Height * 1.0);
var newwidth = (int)(img.Width * newrate); //높이값 다시 계산
var newimg = new System.Drawing.Bitmap(newwidth, 480);
var g = System.Drawing.Graphics.FromImage(newimg);
g.DrawImage(img, new System.Drawing.Rectangle(0, 0, newwidth,480));
g.DrawImage(img, new System.Drawing.Rectangle(0, 0, newwidth, 480));
g.Dispose();
img = (System.Drawing.Image)(newimg.Clone());
}
@@ -114,11 +115,12 @@ namespace FCOMMON
{
cmd.ExecuteNonQuery();
retval = true;
}catch (Exception ex)
}
catch (Exception ex)
{
}
cn.Close();
cn.Dispose();
return retval;
@@ -160,17 +162,17 @@ namespace FCOMMON
cn.Dispose();
return retval;
}
public static System.Drawing.Image GetImageData(string table,string field,int idx)
public static System.Drawing.Image GetImageData(string table, string field, int idx)
{
var cn = getCn();
cn.Open();
string sql = "select " + field + " from "+table+" where idx = " + idx.ToString();
string sql = "select " + field + " from " + table + " where idx = " + idx.ToString();
var cmd = new SqlCommand(sql, cn);
var data = cmd.ExecuteScalar() as byte[];
System.Drawing.Bitmap bmp = null;
if(data != null)
if (data != null)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
bmp = new System.Drawing.Bitmap(ms, true);
@@ -221,7 +223,7 @@ namespace FCOMMON
cn.Dispose();
return retval;
}
/// <summary>
/// 서플라이정보를 찾습니다. 1개의데이터가 검색된 경우에만 사용 됩니다.
@@ -231,7 +233,7 @@ namespace FCOMMON
/// <param name="nameK"></param>
/// <param name="nameE"></param>
/// <returns></returns>
public static Boolean getFindSupply(string nameLike,out int idx,out string nameK,out string nameE)
public static Boolean getFindSupply(string nameLike, out int idx, out string nameK, out string nameE)
{
idx = -1;
nameE = "";
@@ -239,7 +241,7 @@ namespace FCOMMON
var cn = getCn();
cn.Open();
string sql = "select idx,name,name2 from Customs where (name like '%SEEMAX%' or name2 like '%{0}%')";
sql = string.Format(sql, nameLike);
var cmd = new SqlCommand(sql, cn);
@@ -259,7 +261,7 @@ namespace FCOMMON
return cnt == 1;
}
public static sItemInfo getItemInfo(int idx)
{
var cn = getCn();
@@ -271,10 +273,10 @@ namespace FCOMMON
string sql = "select * from Items where gcode='" + FCOMMON.info.Login.gcode + "' and idx = " + idx.ToString();
var cmd = new SqlCommand(sql, cn);
var rdr = cmd.ExecuteReader();
while(rdr.Read())
while (rdr.Read())
{
retval.idx = (int)rdr["idx"];
if(rdr["sid"] != DBNull.Value) retval.sid = rdr["sid"].ToString();
if (rdr["sid"] != DBNull.Value) retval.sid = rdr["sid"].ToString();
if (rdr["model"] != DBNull.Value) retval.model = rdr["model"].ToString();
if (rdr["supply"] != DBNull.Value) retval.supply = rdr["supply"].ToString();
if (rdr["supplyidx"] != DBNull.Value) retval.supplyidx = int.Parse(rdr["supplyidx"].ToString());
@@ -307,16 +309,16 @@ namespace FCOMMON
cmd.Parameters.Add(new SqlParameter("@sid", info.sid));
cmd.Parameters.Add(new SqlParameter("@model", info.model));
cmd.Parameters.Add(new SqlParameter("@supply", info.supply));
cmd.Parameters.Add(new SqlParameter("@supplyidx", info.supplyidx));
cmd.Parameters.Add(new SqlParameter("@supplyidx", info.supplyidx));
cmd.Parameters.Add(new SqlParameter("@name", info.name));
cmd.Parameters.Add(new SqlParameter("@unit", info.unit));
cmd.Parameters.Add(new SqlParameter("@scale", info.scale));
cmd.Parameters.Add(new SqlParameter("@price", info.price));
cmd.Parameters.Add(new SqlParameter("@wuid", FCOMMON.info.Login.no));
cmd.Parameters.Add(new SqlParameter("@wuid", FCOMMON.info.Login.no));
cmd.Parameters.Add(new SqlParameter("@wdate", DateTime.Now));
var iCnt = cmd.ExecuteNonQuery();
if(iCnt == 1)
if (iCnt == 1)
{
cmd.CommandText = "select isnull(idx,-1) from Items where gcode=@gcode and [sid] = @sid";
cmd.Parameters.Clear();
@@ -324,7 +326,7 @@ namespace FCOMMON
cmd.Parameters.Add(new SqlParameter("sid", info.sid));
retval = (int)cmd.ExecuteScalar();
}
cn.Close();
cn.Dispose();
return retval;
@@ -358,7 +360,7 @@ namespace FCOMMON
cn.Dispose();
return retval;
}
public static Dictionary<string,string> getUserList(int baseLevel = 1)
public static Dictionary<string, string> getUserList(int baseLevel = 1)
{
string where = "isnull(level,0) >= " + baseLevel.ToString();
return getTwoColumnList("Users", "id", "name", where, "name");
@@ -372,9 +374,9 @@ namespace FCOMMON
var retval = new sItemInfo();
retval.idx = -1;
string sql = "select [id],[name],concat([name],'(',[id],')') as dispName,[dept],[email],[level],[tel] "+
string sql = "select [id],[name],concat([name],'(',[id],')') as dispName,[dept],[email],[level],[tel] " +
" from Users " +
" where gcode='"+ FCOMMON.info.Login.gcode+"' and [id] <> 'dev' and dept like '%"+ FCOMMON.info.Login.dept.Replace("'","''") +"%' order by [name]";
" where gcode='" + FCOMMON.info.Login.gcode + "' and [id] <> 'dev' and dept like '%" + FCOMMON.info.Login.dept.Replace("'", "''") + "%' order by [name]";
var cmd = new SqlCommand(sql, cn);
var da = new SqlDataAdapter(sql, cn);
var ds = new System.Data.DataSet();
@@ -385,14 +387,14 @@ namespace FCOMMON
else return null;
}
private static Dictionary<string,string> MakeDataTable(List<string> list)
private static Dictionary<string, string> MakeDataTable(List<string> list)
{
var retval = new Dictionary<string, string>();
foreach (var item in list)
retval.Add(item, item);
return retval;
}
private static System.Data.DataTable MakeDataTable(Dictionary<string,string> list)
private static System.Data.DataTable MakeDataTable(Dictionary<string, string> list)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Key");
@@ -420,118 +422,150 @@ namespace FCOMMON
var list = getProjectList(StateCode);
return MakeDataTable(list);
}
public static Dictionary<string,string> getCodeList(string GroupCode="99")
public static Dictionary<string, string> getCodeList(string GroupCode = "99")
{
string where = "Grp = '{0}'";
where = string.Format(where, GroupCode);
return getTwoColumnList("Common", "code", "memo", where, "code");
}
public static string getCodeSavlue(string GroupCode, string code)
{
var cn = getCn();
cn.Open();
var sql = "select isnull(SValue,'')" +
" from Common" +
" where gcode='" + FCOMMON.info.Login.gcode + "' and Grp = '{0}' and code = '{1}'";
public static string getCodeSavlue(string GroupCode, string code)
{
var cn = getCn();
cn.Open();
var sql = "select isnull(SValue,'')" +
" from Common" +
" where gcode='" + FCOMMON.info.Login.gcode + "' and Grp = '{0}' and code = '{1}'";
sql = string.Format(sql, GroupCode, code);
var cmd = new SqlCommand(sql, cn);
var data = cmd.ExecuteScalar();
cmd.Dispose();
cn.Close();
cn.Dispose();
return data.ToString();
}
sql = string.Format(sql, GroupCode, code);
var cmd = new SqlCommand(sql, cn);
var data = cmd.ExecuteScalar();
cmd.Dispose();
cn.Close();
cn.Dispose();
return data.ToString();
}
public struct sCodeData
{
public string code;
public string title;
public string svalue;
public string grp;
}
public static sCodeData getCodeBySvalue(string GroupCode, string svalue)
{
var retval = new sCodeData();
var cn = getCn();
cn.Open();
var sql = "select isnull(code,''),isnull(memo,'')" +
" from Common" +
" where gcode='" + FCOMMON.info.Login.gcode + "' and Grp = '{0}' and svalue = '{1}'";
sql = string.Format(sql, GroupCode, svalue);
var cmd = new SqlCommand(sql, cn);
var da = cmd.ExecuteReader();
while (da.Read())
{
retval.code = da[0].ToString();
retval.title = da[1].ToString();
}
cmd.Dispose();
cn.Close();
cn.Dispose();
retval.grp = GroupCode;
retval.svalue = svalue;
return retval;
}
/// <summary>
/// 지정된 프로젝트의 마지막 업무일지 데이터를 반환함
/// </summary>
/// <param name="projectIdx"></param>
/// <returns></returns>
public static System.Data.DataTable getLastJobReportData(string uid,int projectIdx)
{
var cn = getCn();
cn.Open();
var sql = "select top 1 * from JobReport" +
" where gcode ='"+ FCOMMON.info.Login.gcode + "' and isnull(pidx,-1)=" + projectIdx.ToString() +
" and uid ='" + uid + "'" +
" order by pdate desc, idx desc";
var da = new SqlDataAdapter(sql, cn);
var ds = new System.Data.DataSet();
da.Fill(ds);
cn.Close();
if (ds.Tables.Count > 0) return ds.Tables[0];
else return null;
}
public static System.Data.DataTable getLastJobReportDatabyProjectName(string uid, string prjName)
{
var cn = getCn();
cn.Open();
var sql = "select top 1 * from JobReport" +
" where gcode='" + FCOMMON.info.Login.gcode + "' and isnull(projectName,'') like '" + prjName + "'" +
" and uid ='" + uid + "'" +
" order by pdate desc, idx desc";
var da = new SqlDataAdapter(sql, cn);
var ds = new System.Data.DataSet();
da.Fill(ds);
cn.Close();
if (ds.Tables.Count > 0) return ds.Tables[0];
else return null;
}
public static System.Data.DataTable getLastJobReportData(string uid, string type)
{
var cn = getCn();
cn.Open();
var sql = "select top 1 * from JobReport" +
" where gcode = '" + FCOMMON.info.Login.gcode + "' and isnull([type],'')='" + type + "'" +
" and uid ='" + uid + "'" +
" order by pdate desc, idx desc";
var da = new SqlDataAdapter(sql, cn);
var ds = new System.Data.DataSet();
da.Fill(ds);
cn.Close();
if (ds.Tables.Count > 0) return ds.Tables[0];
else return null;
}
public static System.Data.DataTable getLastJobReportData(string uid, int projectIdx)
{
var cn = getCn();
cn.Open();
var sql = "select top 1 * from JobReport" +
" where gcode ='" + FCOMMON.info.Login.gcode + "' and isnull(pidx,-1)=" + projectIdx.ToString() +
" and uid ='" + uid + "'" +
" order by pdate desc, idx desc";
var da = new SqlDataAdapter(sql, cn);
var ds = new System.Data.DataSet();
da.Fill(ds);
cn.Close();
if (ds.Tables.Count > 0) return ds.Tables[0];
else return null;
}
public static System.Data.DataTable getLastJobReportDatabyProjectName(string uid, string prjName)
{
var cn = getCn();
cn.Open();
var sql = "select top 1 * from JobReport" +
" where gcode='" + FCOMMON.info.Login.gcode + "' and isnull(projectName,'') like '" + prjName + "'" +
" and uid ='" + uid + "'" +
" order by pdate desc, idx desc";
var da = new SqlDataAdapter(sql, cn);
var ds = new System.Data.DataSet();
da.Fill(ds);
cn.Close();
if (ds.Tables.Count > 0) return ds.Tables[0];
else return null;
}
public static System.Data.DataTable getLastJobReportData(string uid, string type)
{
var cn = getCn();
cn.Open();
var sql = "select top 1 * from JobReport" +
" where gcode = '" + FCOMMON.info.Login.gcode + "' and isnull([type],'')='" + type + "'" +
" and uid ='" + uid + "'" +
" order by pdate desc, idx desc";
var da = new SqlDataAdapter(sql, cn);
var ds = new System.Data.DataSet();
da.Fill(ds);
cn.Close();
if (ds.Tables.Count > 0) return ds.Tables[0];
else return null;
}
public static System.Data.DataTable getCodeTable(string GroupCode = "99")
{
public static System.Data.DataTable getCodeTable(string GroupCode = "99")
{
System.Data.DataTable retval = new System.Data.DataTable();
retval.Columns.Add("Code");
retval.Columns.Add("Value");
retval.Columns.Add("SValue");
System.Data.DataTable retval = new System.Data.DataTable();
retval.Columns.Add("Code");
retval.Columns.Add("Value");
retval.Columns.Add("SValue");
var cn = getCn();
cn.Open();
var sql = "select isnull(code,''),isnull(memo ,''),isnull(svalue,'')" +
" from common" +
" where gcode='" + FCOMMON.info.Login.gcode + "' and grp = '" + GroupCode + "'" +
" and isnull(code,'') <> ''" +
" order by isnull(memo,'')";
var cmd = new SqlCommand(sql, cn);
var rdr = cmd.ExecuteReader();
while (rdr.Read())
{
retval.Rows.Add(new string[]{ rdr[0].ToString(), rdr[1].ToString(),rdr[2].ToString()});
}
rdr.Close();
cmd.Dispose();
cn.Close();
cn.Dispose();
return retval;
}
public static Dictionary<string, string> getTwoColumnList(string table, string col1, string col2, string where = "", string order = "")
var cn = getCn();
cn.Open();
var sql = "select isnull(code,''),isnull(memo ,''),isnull(svalue,'')" +
" from common" +
" where gcode='" + FCOMMON.info.Login.gcode + "' and grp = '" + GroupCode + "'" +
" and isnull(code,'') <> ''" +
" order by isnull(memo,'')";
var cmd = new SqlCommand(sql, cn);
var rdr = cmd.ExecuteReader();
while (rdr.Read())
{
retval.Rows.Add(new string[] { rdr[0].ToString(), rdr[1].ToString(), rdr[2].ToString() });
}
rdr.Close();
cmd.Dispose();
cn.Close();
cn.Dispose();
return retval;
}
public static Dictionary<string, string> getTwoColumnList(string table, string col1, string col2, string where = "", string order = "")
{
Dictionary<string, string> retval = new Dictionary<string, string>();
var cn = getCn();
cn.Open();
var sql = "select isnull({1},''),isnull({2},'')" +
" from {0} "+
" from {0} " +
" where gcode = '" + FCOMMON.info.Login.gcode + "' ";
if (where != "") sql += " and " + where;
if (where != "") sql += " and " + where;
if (order != "") sql += " order by " + order;
sql = string.Format(sql,table, col1, col2);
sql = string.Format(sql, table, col1, col2);
var cmd = new SqlCommand(sql, cn);
var rdr = cmd.ExecuteReader();
while (rdr.Read())
@@ -544,13 +578,13 @@ namespace FCOMMON
cn.Dispose();
return retval;
}
public static Dictionary<string,string> getGroupTable(string GroupColumn, string table, string where = "", Boolean desc = false)
public static Dictionary<string, string> getGroupTable(string GroupColumn, string table, string where = "", Boolean desc = false)
{
var list = getGroupList(GroupColumn, table, where, desc);
return MakeDataTable(list);
}
/// <summary>
/// 데이터중 첫번째 자료를 반환 합니다.
/// </summary>
@@ -559,7 +593,7 @@ namespace FCOMMON
/// <param name="where"></param>
/// <param name="order"></param>
/// <returns></returns>
public static String getFirstValue(string column,string table,string where="",string order="")
public static String getFirstValue(string column, string table, string where = "", string order = "")
{
string retval = string.Empty;
var cn = getCn();
@@ -628,13 +662,14 @@ namespace FCOMMON
total = 0;
ot = 0;
}
finally {
finally
{
if (cn != null) cn.Dispose();
}
}
public static int addItem(string pumname,string sid, string model, decimal price, string supply ,int supplyidx = -1,byte[] pic = null)
public static int addItem(string pumname, string sid, string model, decimal price, string supply, int supplyidx = -1, byte[] pic = null)
{
var cn = getCn();
@@ -643,14 +678,14 @@ namespace FCOMMON
int retval = -1;
var cmd2 = new SqlCommand("", cn);
cmd2.CommandText = string.Format( "select count(*) from Items " +
" where ISNULL(REPLACE(name, ' ', '') + REPLACE(model, ' ', ''), '') = '{0}'",pumname.Trim().Replace("'","''") + model.Trim().Replace("'","''"));
cmd2.CommandText = string.Format("select count(*) from Items " +
" where ISNULL(REPLACE(name, ' ', '') + REPLACE(model, ' ', ''), '') = '{0}'", pumname.Trim().Replace("'", "''") + model.Trim().Replace("'", "''"));
var cnt = int.Parse(cmd2.ExecuteScalar().ToString());
if (cnt == 0)
{
DateTime wdate = DateTime.Now;
if(pic == null)
if (pic == null)
{
cmd2.CommandText = "insert into items(gcode,cate,name,sid,model,scale,unit,supply,supplyidx,price,wuid,wdate)" +
"values(@gcode,@cate,@name,@sid,@model,@scale,@unit,@supply,@supplyidx,@price,@wuid,@wdate)";
@@ -670,7 +705,7 @@ namespace FCOMMON
cmd2.Parameters.Add(new SqlParameter("scale", 1.0));
cmd2.Parameters.Add(new SqlParameter("unit", "EA"));
cmd2.Parameters.Add(new SqlParameter("supply", supply));
if (pic != null) cmd2.Parameters.Add(new SqlParameter("image", pic));
if (pic != null) cmd2.Parameters.Add(new SqlParameter("image", pic));
cmd2.Parameters.Add(new SqlParameter("supplyidx", supplyidx));
cmd2.Parameters.Add(new SqlParameter("price", price));
cmd2.Parameters.Add(new SqlParameter("wuid", FCOMMON.info.Login.no));
@@ -695,7 +730,7 @@ namespace FCOMMON
return retval;
}
public static Boolean UpdateItemSID(int itemIdx,string sid)
public static Boolean UpdateItemSID(int itemIdx, string sid)
{
var cn = getCn();
cn.Open();
@@ -715,16 +750,16 @@ namespace FCOMMON
return retval != 0;
}
public static List<String> getGroupList(string GroupColumn, string table, string where = "",Boolean desc=false,Boolean useColumncover=true)
public static List<String> getGroupList(string GroupColumn, string table, string where = "", Boolean desc = false, Boolean useColumncover = true)
{
List<string> retval = new List<string>();
var cn = getCn();
cn.Open();
var sql = "select {0} " +
" from {1} " +
" where gcode='" +FCOMMON.info.Login.gcode + "' and isnull({0},'') != '' ";
" where gcode='" + FCOMMON.info.Login.gcode + "' and isnull({0},'') != '' ";
if(table.ToUpper() == "USERS")
if (table.ToUpper() == "USERS")
sql = "select {0} " +
" from {1} " +
" where isnull({0},'') != '' ";
@@ -739,7 +774,7 @@ namespace FCOMMON
if (useColumncover)
sql = string.Format(sql, "[" + GroupColumn + "]", table);
else
sql = string.Format(sql, GroupColumn , table);
sql = string.Format(sql, GroupColumn, table);
var cmd = new SqlCommand(sql, cn);
var rdr = cmd.ExecuteReader();
while (rdr.Read())
@@ -769,7 +804,7 @@ namespace FCOMMON
if (rdr == null) return string.Empty;
else return rdr.ToString();
}
public static Boolean setPathKJ(string dept,string path)
public static Boolean setPathKJ(string dept, string path)
{
var cn = getCn();
cn.Open();
@@ -787,9 +822,9 @@ namespace FCOMMON
return rdr > 0;
}
public static List<String> getDateList(string table, string where = "",Boolean desc =false)
public static List<String> getDateList(string table, string where = "", Boolean desc = false)
{
return getGroupList("pdate", table, where,desc);
return getGroupList("pdate", table, where, desc);
}
public static int UpdateItemIndexbySID()
@@ -797,7 +832,7 @@ namespace FCOMMON
int retval = 0;
var cn1 = getCn();
cn1.Open();
var cn2 = getCn();
cn2.Open();
@@ -809,11 +844,11 @@ namespace FCOMMON
" isnull(pumprice,0) as pumprice, " +
" isnull(supply,'') as supply, " +
" isnull(supplyidx,-1) as supplyidx" +
" from purchase " +
" where gcode='" + FCOMMON.info.Login.gcode + "' and isnull(sid,'') <> '' and " +
" isnull(sid,'') <> '신규'" +
" and isnull(pumidx,-1) = -1 " +
" and len(sid) = 9" +
" from purchase " +
" where gcode='" + FCOMMON.info.Login.gcode + "' and isnull(sid,'') <> '' and " +
" isnull(sid,'') <> '신규'" +
" and isnull(pumidx,-1) = -1 " +
" and len(sid) = 9" +
" and isnull(pumname,'') <> ''";
var cmd2 = new SqlCommand("", cn2);
@@ -832,13 +867,13 @@ namespace FCOMMON
var idx = int.Parse(rdr["idx"].ToString());
//아이템정보에서 이 sid 가 1개 존재한다면 그것에 연결한다.
var sql2 = "select isnull(idx,-1) from Items where gcode='" + FCOMMON.info.Login.gcode + "' and [sid] = '"+sid+"'";
var sql2 = "select isnull(idx,-1) from Items where gcode='" + FCOMMON.info.Login.gcode + "' and [sid] = '" + sid + "'";
cmd2.CommandText = sql2;
var itemdata = cmd2.ExecuteScalar();
if(itemdata != null && itemdata.ToString() != "-1")
if (itemdata != null && itemdata.ToString() != "-1")
{
cmd2.CommandText = "update purchase set pumidx = " + itemdata.ToString() +
cmd2.CommandText = "update purchase set pumidx = " + itemdata.ToString() +
" where gcode='" + FCOMMON.info.Login.gcode + "' and idx=" + idx.ToString();
retval += cmd2.ExecuteNonQuery();
}
@@ -852,17 +887,17 @@ namespace FCOMMON
cmd2.Parameters.Add(new SqlParameter("name", pumname));
cmd2.Parameters.Add(new SqlParameter("sid", sid));
cmd2.Parameters.Add(new SqlParameter("model", pummodel));
cmd2.Parameters.Add(new SqlParameter("scale",1.0));
cmd2.Parameters.Add(new SqlParameter("scale", 1.0));
cmd2.Parameters.Add(new SqlParameter("unit", pumunit));
cmd2.Parameters.Add(new SqlParameter("supply", supply));
cmd2.Parameters.Add(new SqlParameter("supplyidx", supplyidx));
cmd2.Parameters.Add(new SqlParameter("price", pumprice));
cmd2.Parameters.Add(new SqlParameter("wuid", "dev"));
cmd2.Parameters.Add(new SqlParameter("wdate", DateTime.Now));
retval += cmd2.ExecuteNonQuery();
retval += cmd2.ExecuteNonQuery();
}
}
cmd2.Dispose();
cmd.Dispose();