/// <summary> /// 更新一筆資料 /// </summary> /// <param name="CIC">傳入存放更新資料的SIS.Configuration.ClsItemsConfig CIC</param> /// <returns></returns> public bool Update(SIS.Configuration.ClsItemsConfig CIC) { InitDB(); string updateCmd; updateCmd = "UPDATE " + TableName + " SET "; updateCmd = updateCmd + " ItemsID='" + CIC.ItemsID + "',"; updateCmd = updateCmd + " NAME='" + CIC.NAME + "',"; updateCmd = updateCmd + " ItemsType='" + CIC.ItemsType + "',"; updateCmd = updateCmd + " Specifications='" + CIC.Specifications + "',"; updateCmd = updateCmd + " ItemsUnit='" + CIC.ItemsUnit + "',"; updateCmd = updateCmd + " SellingPrice=" + CIC.SellingPrice + ","; updateCmd = updateCmd + " CostPrice=" + CIC.CostPrice + ","; updateCmd = updateCmd + " MSRP=" + CIC.MSRP + ","; updateCmd = updateCmd + " ManufacturerID='" + CIC.ManufacturerID + "',"; updateCmd = updateCmd + " Inventory=" + CIC.Inventory + ","; updateCmd = updateCmd + " SafeInventory=" + CIC.SafeInventory + ","; updateCmd = updateCmd + " Notes='" + CIC.Notes + "'"; updateCmd = updateCmd + " WHERE ItemsID='" + CIC.ItemsID + "'"; try { cmd = new SqlCommand(updateCmd, conn); cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch (Exception ex) { errorMsg = ex.Message; conn.Close(); return(false); } }
/// <summary> /// 新增一筆資料 /// </summary> /// <param name="CIC">傳入存放更新資料的SIS.Configuration.ClsItemsConfig</param> /// <returns></returns> public bool InsertData(SIS.Configuration.ClsItemsConfig CIC) { InitDB(); string insertCmd; insertCmd = "Insert Into " + TableName + " (ItemsID,NAME,ItemsType,Specifications,ItemsUnit,SellingPrice,CostPrice,MSRP,ManufacturerID,Inventory,SafeInventory,Notes"; insertCmd = insertCmd + ") Values("; insertCmd = insertCmd + "'" + CIC.ItemsID + "',"; insertCmd = insertCmd + "'" + CIC.NAME + "',"; insertCmd = insertCmd + "'" + CIC.ItemsType + "',"; insertCmd = insertCmd + "'" + CIC.Specifications + "',"; insertCmd = insertCmd + "'" + CIC.ItemsUnit + "',"; insertCmd = insertCmd + "" + CIC.SellingPrice + ","; insertCmd = insertCmd + "" + CIC.CostPrice + ","; insertCmd = insertCmd + "" + CIC.MSRP + ","; insertCmd = insertCmd + "'" + CIC.ManufacturerID + "',"; insertCmd = insertCmd + "" + CIC.Inventory + ","; insertCmd = insertCmd + "" + CIC.SafeInventory + ","; insertCmd = insertCmd + "'" + CIC.Notes + "'"; insertCmd = insertCmd + ")"; try { cmd = new SqlCommand(insertCmd, conn); cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch (Exception ex) { errorMsg = ex.Message; conn.Close(); return(false); } }