public static bool SetRegDelete(string Stock_Code, string User_ID) { string sSql = @""; sSql += " DELETE FROM USER_STOCK "; sSql += " WHERE STOCK_CODE = '" + Stock_Code + "'"; sSql += " AND USER_ID = " + User_ID; int Result; using (var db = new MSSQLDB()) { Result = db.Execute(sSql); } if (Result > 0) { return(true); } else { return(false); } }
public static int SetStockDelete(string Stock_Code) { string sSql = @""; sSql += " DELETE FROM STOCK_INFO "; sSql += " WHERE STOCK_CODE = '" + Stock_Code + "'"; int Result; using (var db = new MSSQLDB()) { Result = db.Execute(sSql); } return(Result); }
public static int SetUser(string UserCode, string PassWord, string UserAlias, string UserPhone, string UserEmail) { string sSql = @""; sSql += " INSERT INTO USER_MST ( USER_CODE, PASSWORD, USER_ALIAS, USER_PHONE, USER_EMAIL, USER_STATUS )"; sSql += " VALUES ( '" + UserCode + "', '" + PassWord + "', '" + UserAlias + "', '" + UserPhone + "', '" + UserEmail + "', 'Y')"; int result; using (var db = new MSSQLDB()) { result = db.Execute(sSql); } return(result); }
public static int SetRemarkSave(string Stock_Code, string Stock_Remark) { string sSql = @""; sSql += " UPDATE STOCK_CLASS "; sSql += " SET STOCK_REMARK = '" + Stock_Remark + "'"; sSql += " WHERE STOCK_CODE = '" + Stock_Code + "'"; int Result; using (var db = new MSSQLDB()) { Result = db.Execute(sSql); } return(Result); }
public static bool SetSavePrice(string Stock_Code, string User_ID, string Buy_Price, string Sell_Price, string Avg_Price) { string sSql = @""; sSql += " UPDATE USER_STOCK "; sSql += " SET BUY_PRICE = " + Buy_Price; sSql += " , SELL_PRICE = " + Sell_Price; sSql += " , AVG_PRICE = " + Avg_Price; sSql += " WHERE STOCK_CODE = '" + Stock_Code + "'"; sSql += " AND USER_ID = " + User_ID; int Result; using (var db = new MSSQLDB()) { Result = db.Execute(sSql); } return(true); }
public static int SetKospiPoint(string Kospi_Point) { string sSql; int result; string YD_POINT; // 오늘이 토,일이면 저장하지 않고 패쓰 DateTime nowDt = DateTime.Now; if (nowDt.DayOfWeek == DayOfWeek.Saturday || nowDt.DayOfWeek == DayOfWeek.Sunday) { return(0); } // 어제 날짜 지수 가져오기 sSql = @""; sSql += " SELECT MAX(INDEX_POINT) INDEX_POINT "; sSql += " FROM INDEX_POINT A "; sSql += " WHERE STOCK_MARKET = 'KOSPI'"; sSql += " AND INDEX_DATE = ( "; sSql += " SELECT MAX(INDEX_DATE) INDEX_DATE "; sSql += " FROM INDEX_POINT A "; sSql += " WHERE STOCK_MARKET = 'KOSPI'"; sSql += " AND INDEX_DATE < "; sSql += " ( SELECT TOP 1 INDEX_DATE"; sSql += " FROM INDEX_POINT"; sSql += " WHERE STOCK_MARKET = 'KOSPI'"; sSql += " AND INDEX_DATE > GETDATE() - 10 "; sSql += " ORDER BY INDEX_DATE DESC "; sSql += " ) "; sSql += " ) "; DataSet user; using (var db = new MSSQLDB()) { user = db.Query(sSql); } YD_POINT = user.Tables[0].Rows[0][0].ToString(); sSql = @""; sSql += " MERGE INTO INDEX_POINT A "; sSql += " USING ( SELECT CONVERT(CHAR(10),GETDATE(),23) INDEX_DATE, 'KOSPI' STOCK_MARKET ) B"; sSql += " ON (A.STOCK_MARKET = B.STOCK_MARKET AND A.INDEX_DATE = B.INDEX_DATE )"; sSql += " WHEN MATCHED THEN "; sSql += " UPDATE"; sSql += " SET INDEX_POINT = " + Kospi_Point.ToString(); sSql += " , INDEX_HIGH = " + Kospi_Point.ToString(); sSql += " , INDEX_START = " + YD_POINT; sSql += " , INDEX_LOW = " + YD_POINT; sSql += " WHEN NOT MATCHED THEN "; sSql += " INSERT (STOCK_MARKET, INDEX_DATE, INDEX_POINT, INDEX_START, INDEX_LOW, INDEX_HIGH, CREATE_DATE)"; sSql += " VALUES ('KOSPI', CONVERT(CHAR(10), GETDATE(), 23), "+ Kospi_Point.ToString() + ", " + YD_POINT + ", " + YD_POINT + ", " + Kospi_Point.ToString() + ", GETDATE() );"; using (var db = new MSSQLDB()) { result = db.Execute(sSql); } return(result); }
public static bool SetStockInsert(string Reg_Code, string Reg_Name, string Reg_Class1, string Reg_Class2, string Reg_Remark, string User_ID) { int Result = 0; string sSql = @""; sSql += " MERGE INTO STOCK_INFO A "; sSql += " USING ( SELECT '" + Reg_Code + "' STOCK_CODE ) B"; sSql += " ON (A.STOCK_CODE = B.STOCK_CODE )"; sSql += " WHEN MATCHED THEN "; sSql += " UPDATE"; sSql += " SET STOCK_CODE = '" + Reg_Code + "'"; sSql += " , STOCK_NAME = '" + Reg_Name + "'"; sSql += " , UPDATE_USER = "******" WHEN NOT MATCHED THEN "; sSql += " INSERT (STOCK_CODE, STOCK_NAME, CREATE_USER)"; sSql += " VALUES ('"+ Reg_Code + "', '" + Reg_Name + "' , " + User_ID + " );"; int result; using (var db = new MSSQLDB()) { result = db.Execute(sSql); } sSql = @""; sSql += " UPDATE STOCK_CLASS "; sSql += " SET STOCK_REMARK = '" + Reg_Remark + "',"; sSql += " STOCK_CLASS1 = '" + Reg_Class1 + "',"; sSql += " STOCK_CLASS2 = '" + Reg_Class2 + "'"; sSql += " FROM STOCK_CLASS A "; sSql += " WHERE A.STOCK_CODE = '" + Reg_Code + "'"; using (var db = new MSSQLDB()) { result = db.Execute(sSql); } sSql = @""; sSql += " UPDATE STOCK_INFO "; sSql += " SET STOCK_CLASS1 = B.STOCK_CLASS1, "; sSql += " STOCK_CLASS2 = B.STOCK_CLASS2 "; sSql += " FROM STOCK_INFO A "; sSql += " , STOCK_CLASS B "; sSql += " WHERE A.STOCK_CODE = '" + Reg_Code + "'"; sSql += " AND B.STOCK_CODE = A.STOCK_CODE "; using (var db = new MSSQLDB()) { result = db.Execute(sSql); } // USER_STOCK 등록 if (!(string.IsNullOrEmpty(User_ID) || (User_ID == "0"))) { sSql = @""; sSql += " MERGE INTO USER_STOCK A "; sSql += " USING ( SELECT '" + Reg_Code + "' STOCK_CODE, " + User_ID + " USER_ID ) B"; sSql += " ON (A.STOCK_CODE = B.STOCK_CODE AND A.USER_ID = B.USER_ID )"; sSql += " WHEN MATCHED THEN "; sSql += " UPDATE"; sSql += " SET STOCK_REMARK = '" + Reg_Remark + "'"; sSql += " WHEN NOT MATCHED THEN "; sSql += " INSERT (STOCK_CODE, STOCK_NAME, USER_ID, STOCK_REMARK )"; sSql += " VALUES ('"+ Reg_Code + "', '" + Reg_Name + "', " + User_ID + ", '" + Reg_Remark + "' );"; using (var db = new MSSQLDB()) { result = db.Execute(sSql); } } if (result > 0) { return(true); } else { return(false); } }