/// <summary> /// 更新一筆資料 /// </summary> /// <param name="CMC">傳入存放更新資料的SIS.Configuration.ClsManufacturerConfig</param> /// <returns></returns> public bool Update(SIS.Configuration.ClsManufacturerConfig CMC) { InitDB(); string updateCmd; updateCmd = "UPDATE " + TableName + " SET "; updateCmd = updateCmd + " ManufacturerID='" + CMC.ManufacturerID + "',"; updateCmd = updateCmd + " CNAME='" + CMC.CNAME + "',"; updateCmd = updateCmd + " ENAME='" + CMC.ENAME + "',"; updateCmd = updateCmd + " UnifiedBusinessNo='" + CMC.UnifiedBusinessNo + "',"; updateCmd = updateCmd + " Owner='" + CMC.Owner + "',"; updateCmd = updateCmd + " Contact='" + CMC.Contact + "',"; updateCmd = updateCmd + " Phone='" + CMC.Phone + "',"; updateCmd = updateCmd + " MobilePhone='" + CMC.MobilePhone + "',"; updateCmd = updateCmd + " Fax='" + CMC.Fax + "',"; updateCmd = updateCmd + " Address='" + CMC.Address + "',"; updateCmd = updateCmd + " WebSite='" + CMC.WebSite + "',"; updateCmd = updateCmd + " Notes='" + CMC.Notes + "'"; updateCmd = updateCmd + " WHERE ManufacturerID='" + CMC.ManufacturerID + "'"; 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="CMC">傳入存放更新資料的SIS.Configuration.ClsManufacturerConfig</param> /// <returns></returns> public bool InsertData(SIS.Configuration.ClsManufacturerConfig CMC) { InitDB(); string insertCmd; insertCmd = "Insert Into " + TableName + " (ManufacturerID,CNAME,ENAME,UnifiedBusinessNo,Owner,Contact,Phone,MobilePhone,Fax,Address,WebSite,Notes"; insertCmd = insertCmd + ") Values("; insertCmd = insertCmd + "'" + CMC.ManufacturerID + "',"; insertCmd = insertCmd + "'" + CMC.CNAME + "',"; insertCmd = insertCmd + "'" + CMC.ENAME + "',"; insertCmd = insertCmd + "'" + CMC.UnifiedBusinessNo + "',"; insertCmd = insertCmd + "'" + CMC.Owner + "',"; insertCmd = insertCmd + "'" + CMC.Contact + "',"; insertCmd = insertCmd + "'" + CMC.Phone + "',"; insertCmd = insertCmd + "'" + CMC.MobilePhone + "',"; insertCmd = insertCmd + "'" + CMC.Fax + "',"; insertCmd = insertCmd + "'" + CMC.Address + "',"; insertCmd = insertCmd + "'" + CMC.WebSite + "',"; insertCmd = insertCmd + "'" + CMC.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); } }