private void efnDel()
        {
            string strSQL = "";

            if (txtDelName.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("입력해주세요");
                return;
            }
            strSQL  = @"
                        DELETE 
                         FROM Code";
            strSQL += @"
                        WHERE Company = '" + txtDelName.Text + "' OR CodeNum = '" + txtDelName.Text + "'";

            int iresult = Network.ExecDB(strSQL);

            if (iresult > 0)
            {
                MessageBox.Show("삭제성공");
            }
            else
            {
                MessageBox.Show("삭제실패");
            }
            txtDelName.Clear();
        }
        private void MemoMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            string strDate     = chkDate.Checked ? "Y" : "N";
            string strTitle    = chkTitle.Checked ? "Y" : "N";
            string strContents = chkContents.Checked ? "Y" : "N";
            string strWhite    = chkWhite.Checked ? "Y" : "N";
            string strGray     = chkGray.Checked ? "Y" : "N";
            string strBlue     = chkBlue.Checked ? "Y" : "N";
            string strYellow   = chkYellow.Checked ? "Y" : "N";
            string strRed      = chkRed.Checked ? "Y" : "N";

            strSQL = @"UPDATE InitMemoOpt
                          SET chkDate = '" + strDate + @"'
                             , DateF = '" + dteF.Value.ToString("yyyyMMdd") + @"'
                             , DateS = '" + dteS.Value.ToString("yyyyMMdd") + @"'
                             , chkTitle = '" + strTitle + @"'
                             , chkWhite = '" + strWhite + @"'
                             , chkGray = '" + strGray + @"'
                             , chkBlue = '" + strBlue + @"'
                             , chkYellow = '" + strYellow + @"'
                             , chkRed = '" + strRed + @"'
                             , chkContents = '" + strContents + @"'";

            Network.ExecDB(strSQL);
        }
Пример #3
0
        //삭제버튼 연결
        private void efnDelete()
        {
            string    strSQL = @"
                                SELECT *
                                  FROM Interest
                                 WHERE COMPANY = '" + cboStoSearch.Text.ToUpper() + @"'
                                   AND IFNULL(InterName,'') = '" + cboInter.Text + @"';";
            DataTable dt     = Network.GetDBTable(strSQL);

            if (dt.Rows.Count == 1)
            {
                strSQL = @"
                            DELETE FROM Interest
                                  WHERE COMPANY = '" + cboStoSearch.Text.ToUpper() + @"'
                                    AND IFNULL(InterName,'') = '" + cboInter.Text + @"';";

                if (Network.ExecDB(strSQL) > 0)
                {
                    MessageBox.Show("삭제하였습니다.");
                }
                else
                {
                    MessageBox.Show("삭제실패");
                }
                mfnInterestBinder();
                //fnInterestSearch();
            }
            else
            {
                MessageBox.Show("관심종목에 없는 종목입니다.");
            }
            cboStoSearch.Text = "";
        }
        private void efnInsert()
        {
            string strSQL = "";

            if (txtInsertName.Text.Replace(" ", "") == "" || txtInsertCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("제대로 입력해주세요");
                return;
            }
            strSQL = @"
                        INSERT INTO Code ( Company, CodeNum)
                        VALUES ('" + txtInsertName.Text + "', '" + txtInsertCode.Text + "');";

            int iresult = Network.ExecDB(strSQL);

            if (iresult > 0)
            {
                MessageBox.Show("입력성공");
            }
            else
            {
                MessageBox.Show("입력실패");
            }
            txtInsertCode.Clear();
            txtInsertCode.Clear();
        }
Пример #5
0
        //관심 DisSeq Down버튼
        private void efnDisSeqDown()
        {
            int intSelectedRow;

            try
            {
                intSelectedRow = dgvView.CurrentCell.RowIndex;
                if (intSelectedRow == dgvView.Rows.Count - 1)
                {
                    return;
                }
            }
            catch (NullReferenceException)
            {
                return;
            }

            DataTable dtDisSeq = Network.GetDBTable(@"SELECT DisSeq 
                                                        FROM Interest 
                                                       WHERE InterName = '" + cboInter.Text + @"'
                                                         AND (Company = '" + dgvView["종목명", intSelectedRow].Value.ToString() + @"'
                                                          OR  Company = '" + dgvView["종목명", intSelectedRow + 1].Value.ToString() + @"')
                                                       ORDER BY DisSeq");

            if (dtDisSeq.Rows.Count != 2)
            {
                MessageBox.Show("SELECT 실패");
                return;
            }

            int intResult;

            intResult = Network.ExecDB(@"UPDATE Interest 
                                            SET DisSeq = '" + dtDisSeq.Rows[1][0].ToString() + @"'
                                          WHERE InterName = '" + cboInter.Text + @"'
                                            AND Company = '" + dgvView["종목명", intSelectedRow].Value.ToString() + @"';
                                
                                         UPDATE Interest
                                            SET DisSeq = '" + dtDisSeq.Rows[0][0].ToString() + @"'
                                          WHERE InterName = '" + cboInter.Text + @"'
                                            AND Company = '" + dgvView["종목명", intSelectedRow + 1].Value.ToString() + @"';");

            if (intResult < 1)
            {
                MessageBox.Show("Update 실패");
                return;
            }

            fnInterestSearch();
            dgvView.Rows[intSelectedRow + 1].Selected = true;
            dgvView.CurrentCell = dgvView.Rows[intSelectedRow + 1].Cells["종목명"];
            dgvView.BeginEdit(true);
        }
Пример #6
0
        //추가버튼 연결
        private void efnInsert()
        {
            if (cboInter.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("관심목록이 빈 값입니다.");
                return;
            }
            string  strSQL = @"
                                SELECT *
                                  FROM Interest
                                 WHERE COMPANY = '" + cboStoSearch.Text.ToUpper() + @"'
                                   AND IFNULL(InterName,'') = '" + cboInter.Text + @"';

                                SELECT *
                                  FROM Code
                                 WHERE COMPANY = '" + cboStoSearch.Text.ToUpper() + @"'";
            DataSet ds     = Network.GetDBSet(strSQL);

            if (ds.Tables[0].Rows.Count >= 1)
            {
                cboStoSearch.Text = "";
            }
            else if (ds.Tables[1].Rows.Count < 1)
            {
                MessageBox.Show("없는 종목입니다.");
            }
            else
            {
                strSQL = @"
                            INSERT INTO Interest(Company, CodeNum, DisSeq, InterName)
                                   SELECT Company
                                        , CodeNum
                                        , IFNULL((SELECT MAX(DisSeq) + 1 AS DisSeq 
                                             FROM Interest 
                                            WHERE IFNULL(InterName,'') = '" + cboInter.Text + @"'
                                            GROUP BY InterName),1) AS DisSeq
                                        , '" + cboInter.Text + @"' 
                                     FROM Code
                                    WHERE COMPANY = '" + cboStoSearch.Text.ToUpper() + "';";

                if (Network.ExecDB(strSQL) > 0)
                {
                    MessageBox.Show("추가하였습니다.");
                }
                else
                {
                    MessageBox.Show("추가실패");
                }
                fnInterestSearch();
            }
            cboStoSearch.Text = "";
        }
Пример #7
0
        //메인메모 바인딩
        private void mfnMainMemoBinder()
        {
            DataTable dt = Network.GetDBTable("SELECT Contents FROM SimpleMemo WHERE CodeNum = 'MainMemo'");

            if (dt.Rows.Count > 0)
            {
                txtMemo.Text = dt.Rows[0]["Contents"].ToString();
            }
            else
            {
                Network.ExecDB("INSERT INTO SimpleMemo (Contents, CodeNum) VALUES ('', 'MainMemo')");
            }
        }
Пример #8
0
        private bool fnSave()
        {
            int iResult = 0;

            if (mIsContents)
            {
                iResult = Network.ExecDB("UPDATE SimpleMemo SET Contents = '" + txtMemo.Text + "' WHERE CodeNum = '" + mCodeNum + "'");
            }
            else
            {
                iResult = Network.ExecDB("INSERT INTO SimpleMemo (Contents, CodeNum) VALUES ('" + txtMemo.Text + "', '" + mCodeNum + "')");
            }
            return(iResult > 0 ? true : false);
        }
        /// <summary>
        /// 내부이벤트 - 팝업 클릭 시 색 정하기
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Color_Click(object sender, EventArgs e)
        {
            string strChoiceColor = sender.ToString().Split(',')[2].Replace("Text: ", "").Replace(" ", "");

            strChoiceColor = strChoiceColor == "흰색" ? "" : strChoiceColor;

            strSQL = @"UPDATE Memo
                          SET Color = '" + strChoiceColor + @"'
                        WHERE Seq = '" + mSelectedSeq + "'";

            Network.ExecDB(strSQL);

            fnReadDB(mSchQuery, dataGridView1.FirstDisplayedScrollingRowIndex);
        }
        private void fnSave(string p_Type, string p_Seq)
        {
            string strSQL = @"
                                UPDATE " + p_Type + @"
                                   SET Memo = '" + txtMemo.Text + @"'
                                 WHERE Seq = '" + p_Seq + @"';
                            ";

            int iresult = Network.ExecDB(strSQL);

            if (iresult > 0)
            {
                MessageBox.Show("저장 성공");
            }
            else
            {
                MessageBox.Show("저장 실패");
            }
        }
        /// <summary>
        /// 로우 지우기
        /// </summary>
        private void fnDel()
        {
            Dictionary <string, string> dicSelected = fnSelectedDic();

            //strSQL = @"DELETE FROM Memo WHERE Seq = " + dicSelected["Seq"];
            strSQL = @"
                       UPDATE Memo
                          SET Valid = 'N'
                        WHERE Seq = " + dicSelected["Seq"];


            if (Network.ExecDB(strSQL) > 0)
            {
                string   strFilePath = @".\FileList\" + dicSelected["날짜"] + @"\";
                string[] strTemp;
                if (Directory.Exists(strFilePath) && dicSelected["FileDetail"] != "")
                {
                    //권한주기
                    DirectorySecurity dSecurity = Directory.GetAccessControl(strFilePath);
                    dSecurity.AddAccessRule(new FileSystemAccessRule(System.Environment.UserDomainName + "\\" + System.Environment.UserName, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow));
                    Directory.SetAccessControl(strFilePath, dSecurity);

                    strTemp = dicSelected["FileDetail"].Split('§');

                    foreach (string a in strTemp)
                    {
                        if (a != "")
                        {
                            File.Delete(strFilePath + a);
                        }
                    }

                    //디렉토리에 아무것도 없으면 디렉토리 지우자
                    DirectoryInfo DirInfo = new DirectoryInfo(strFilePath);
                    if (DirInfo.GetFiles().Length < 1)
                    {
                        DirInfo.Delete();
                    }
                }

                MessageBox.Show("삭제 완료");
            }
        }
        /// <summary>
        /// 저장버튼
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strSql = "";

            strSql  = @"
                        DELETE FROM FTP;";
            strSql += @"
                        INSERT INTO FTP ( 'IP', 'ID', 'PW')
                        VALUES ( '" + Network.Encrypt(txtAddress.Text) + @"',
                                 '" + Network.Encrypt(txtID.Text) + @"',
                                 '" + Network.Encrypt(txtPassWd.Text) + @"' );";

            int iresult = Network.ExecDB(strSql);

            if (iresult > 0)
            {
                MessageBox.Show("저장되었습니다. 재시작하세요");
            }
            else
            {
                MessageBox.Show("저장에 실패하였습니다.");
            }
        }
Пример #13
0
 //관심삭제2 버튼 연결
 private void efnDel2()
 {
     if (btnDel2.Tag.ToString() == "Del2")
     {
         if (MessageBox.Show("'주의'!! 관심목록 삭제입니다!!! 정말 삭제 하시겠습니가? ", "관심목록 삭제", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             if (Network.ExecDB("DELETE FROM Interest WHERE InterName = '" + cboInter.Text + "'") > 0)
             {
                 mfnInterestBinder();
             }
             else
             {
                 MessageBox.Show("삭제 실패");
             }
         }
     }
     else if (btnDel2.Tag.ToString() == "Del2.Cancel" || btnDel2.Tag.ToString() == "Chg.Cancel")
     {
         fnChangeBtn(btnDel2.Tag.ToString(), true);
         cboInter.DropDownStyle = ComboBoxStyle.DropDownList;
         cboInter.SelectedItem  = mInterListName;
     }
 }
        //디비에 넣자
        private void mfnInsertToDb()
        {
            mliStock.Clear();
            string strCode  = "";
            string strQuery = "";

            if (txtDbList.Text.Contains(","))
            {
                for (int i = 0; i < txtDbList.Text.Split(',').Length; i++)
                {
                    mliStock.Add(txtDbList.Text.Split(',')[i].ToUpper());
                }
            }
            else if (txtDbList.Text.Replace(" ", "") == "")
            {
                return;
            }
            else
            {
                mliStock.Add(txtDbList.Text.ToUpper());
            }

            for (int i = 0; i < mliStock.Count; i++)
            {
                strCode = mfnSearchCode(mliStock[i]);
                if (strCode == "")
                {
                    return;
                }
                else
                {
                    mDetailInfo = Parser.GetDetailInfo(strCode, Convert.ToInt32(txtNum.Text) + 60);

                    strQuery = "DELETE  FROM List WHERE Name = '" + mliStock[i] + "'";
                    Network.ExecDB(strQuery, mDbSource);


                    using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(mDbSource))
                    {
                        conn.Open();
                        using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
                        {
                            using (System.Data.SQLite.SQLiteTransaction tran = conn.BeginTransaction())
                            {
                                for (int j = 0; j < mDetailInfo.Length; j++)
                                {
                                    strQuery        = "";
                                    strQuery       += "INSERT INTO List (Name, Date, Price, Volumn, HighPrice, LowPrice, StartPrice)" + "\r\n";
                                    strQuery       += "VALUES( " + "\r\n";
                                    strQuery       += "'" + mliStock[i] + "',";
                                    strQuery       += "'" + mDetailInfo[j].date + "',";
                                    strQuery       += "'" + mDetailInfo[j].price + "',";
                                    strQuery       += "'" + mDetailInfo[j].volumn + "',";
                                    strQuery       += "'" + mDetailInfo[j].highPrice + "',";
                                    strQuery       += "'" + mDetailInfo[j].lowPrice + "',";
                                    strQuery       += "'" + mDetailInfo[j].startPrice + "');" + "\r\n";
                                    cmd.CommandText = strQuery;
                                    cmd.ExecuteNonQuery();
                                }
                                tran.Commit();
                            }
                        }
                        conn.Close();
                    }

                    /*
                     * if (Network.ExecDB(strQuery, mDbSource) == 0)
                     * {
                     *  MessageBox.Show("InsertError");
                     *  return;
                     * }
                     */
                }
            }
        }
Пример #15
0
        /// <summary>
        /// »èÁ¦ ¹öÆ° ¿¬°á
        /// </summary>
        private void efnDel()
        {
            //µðºñ¿¬°á

            string strSQL  = "";
            string strName = dataGridView1.CurrentRow.Cells["Á¾¸ñ¸í"].Value.ToString(); //¼±ÅÃµÈ À̸§

            DataRow[] drr = mds.Tables[0].Select("Á¾·ù = '¸Åµµ' AND Á¾¸ñ¸í = '" + strName + "' AND ÀÜ·® <> ¼ö·®", "Seq DESC");

            if (dataGridView1.CurrentRow.Cells["Á¾·ù"].Value.ToString() == "¸Å¼ö")
            {
                if (dataGridView1.CurrentRow.Cells["ÀÜ·®"].Value.ToString() != dataGridView1.CurrentRow.Cells["¼ö·®"].Value.ToString())
                {
                    MessageBox.Show("ÇØ´ç Á¾¸ñÀÇ °¡Àå ÃÖ±Ù ¸Åµµ¸¦ ¸ÕÀú Áö¿ì½Ê½Ã¿À.\r\n(³¯Â¥ : " + drr[0]["³¯Â¥"].ToString() + ", ¼ö·® : " + drr[0]["¼ö·®"].ToString() + ", °¡°Ý : " + drr[0]["°¡°Ý"].ToString() + ")");
                    return;
                }
                strSQL = @"
                           DELETE FROM Buy
                            WHERE Seq = '" + dataGridView1.CurrentRow.Cells["Seq"].Value.ToString() + @"';
                          ";
                int iresult = Network.ExecDB(strSQL);
                if (iresult > 0)
                {
                    MessageBox.Show("»èÁ¦¼º°ø");
                }
                else
                {
                    MessageBox.Show("»èÁ¦½ÇÆÐ");
                }
            }

            else if (dataGridView1.CurrentRow.Cells["Á¾·ù"].Value.ToString() == "¸Åµµ")
            {
                string strSellSeq;                                                                       // = mds.Tables[1].Rows[0][0].ToString();    //¼±ÅÃµÈ Seq

                int i = 0;                                                                               //¹Ýº¹¹® º¯¼ö

                int intSellQ = Convert.ToInt32(dataGridView1.CurrentRow.Cells["¼ö·®"].Value.ToString()); //ÆǸÅÇÏ°íÀÚ ÇÏ´Â ¼ö·®
                int intQ;                                                                                //buyÀÇ ³²Àº ¼ö·®

                DataRow[] dr = mds.Tables[0].Select("Á¾·ù = '¸Å¼ö' AND Á¾¸ñ¸í = '" + strName + "' AND ÀÜ·® <> ¼ö·®", "Seq DESC");


                strSellSeq = drr[0]["Seq"].ToString();

                if (dataGridView1.CurrentRow.Cells["Seq"].Value.ToString() != strSellSeq)
                {
                    MessageBox.Show("ÇØ´ç Á¾¸ñÀÇ °¡Àå ÃÖ±Ù ¸Åµµ¸¦ ¸ÕÀú Áö¿ì½Ê½Ã¿À.\r\n(³¯Â¥ : " + drr[0]["³¯Â¥"].ToString() + ", ¼ö·® : " + drr[0]["¼ö·®"].ToString() + ", °¡°Ý : " + drr[0]["°¡°Ý"].ToString() + ")");
                    return;
                }
                else
                {
                    strSQL = @"
                                DELETE FROM Revenue
                                 WHERE SellSeq = '" + strSellSeq + @"';
                              ";

                    strSQL += @"
                               DELETE FROM Sell
                                WHERE Seq = '" + strSellSeq + @"'; 
                              ";

                    while (intSellQ > 0)
                    {
                        intQ = Convert.ToInt32(dr[i]["¼ö·®"].ToString()) - Convert.ToInt32(dr[i]["ÀÜ·®"].ToString());

                        if (intSellQ >= intQ)
                        {
                            strSQL  += @"
                                        UPDATE Buy
                                           SET Left = Quantity
                                         WHERE Seq = '" + dr[i]["Seq"].ToString() + @"';
                                       ";
                            intSellQ = intSellQ - intQ;
                        }
                        else
                        {
                            strSQL  += @"
                                        UPDATE Buy
                                           SET Left = " + (Convert.ToInt32(dr[i]["ÀÜ·®"].ToString()) + intSellQ) + @"
                                         WHERE Seq = '" + dr[i]["Seq"].ToString() + @"';
                                       ";
                            intSellQ = 0;
                        }

                        i++;
                    }


                    int iresult = Network.ExecDB(strSQL);
                    if (iresult > 0)
                    {
                        MessageBox.Show("»èÁ¦ ¼º°ø");
                    }
                    else
                    {
                        MessageBox.Show("»èÁ¦½ÇÆÐ");
                    }
                }
            }
            fnReadDB();
        }
Пример #16
0
 //메인메모에서 떠날 때 세이브한다.
 private void txtMemo_Leave(object sender, EventArgs e)
 {
     Network.ExecDB("UPDATE SimpleMemo SET Contents = '" + txtMemo.Text + "' WHERE CodeNum = 'MainMemo'");
 }
        /// <summary>
        /// 체크박스 초기화
        /// </summary>
        private void fnInitOpt()
        {
            DataTable dtOpt = new DataTable();

            strSQL = @" SELECT * 
                          FROM InitMemoOpt";

            dtOpt = Network.GetDBTable(strSQL);

            if (dtOpt.Rows.Count < 1)
            {
                strSQL = @"INSERT INTO InitMemoOpt (chkDate, DateF, DateS, chkTitle, chkWhite, chkGray, chkBlue, chkYellow, chkRed, chkContents, isCopy)
                           VALUES ('Y', '20000101', '20801231', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y')";

                Network.ExecDB(strSQL);

                strSQL = @" SELECT * 
                          FROM InitMemoOpt";
                dtOpt  = Network.GetDBTable(strSQL);
            }

            if (dtOpt.Rows[0]["chkDate"].ToString().ToUpper().Equals("Y"))
            {
                chkDate.Checked = true;
            }
            else
            {
                chkDate.Checked = false;
            }

            dteF.Value = new DateTime(Convert.ToInt32(dtOpt.Rows[0]["DateF"].ToString().Substring(0, 4))
                                      , Convert.ToInt32(dtOpt.Rows[0]["DateF"].ToString().Substring(4, 2))
                                      , Convert.ToInt32(dtOpt.Rows[0]["DateF"].ToString().Substring(6, 2)), 0, 0, 0);

            dteS.Value = new DateTime(Convert.ToInt32(dtOpt.Rows[0]["DateS"].ToString().Substring(0, 4))
                                      , Convert.ToInt32(dtOpt.Rows[0]["DateS"].ToString().Substring(4, 2))
                                      , Convert.ToInt32(dtOpt.Rows[0]["DateS"].ToString().Substring(6, 2)), 0, 0, 0);

            if (dtOpt.Rows[0]["chkTitle"].ToString().ToUpper().Equals("Y"))
            {
                chkTitle.Checked = true;
            }
            else
            {
                chkTitle.Checked = false;
            }

            if (dtOpt.Rows[0]["chkContents"].ToString().ToUpper().Equals("Y"))
            {
                chkContents.Checked = true;
            }
            else
            {
                chkContents.Checked = false;
            }

            if (dtOpt.Rows[0]["chkWhite"].ToString().ToUpper().Equals("Y"))
            {
                chkWhite.Checked = true;
            }
            else
            {
                chkWhite.Checked = false;
            }

            if (dtOpt.Rows[0]["chkGray"].ToString().ToUpper().Equals("Y"))
            {
                chkGray.Checked = true;
            }
            else
            {
                chkGray.Checked = false;
            }

            if (dtOpt.Rows[0]["chkBlue"].ToString().ToUpper().Equals("Y"))
            {
                chkBlue.Checked = true;
            }
            else
            {
                chkBlue.Checked = false;
            }
            if (dtOpt.Rows[0]["chkYellow"].ToString().ToUpper().Equals("Y"))
            {
                chkYellow.Checked = true;
            }
            else
            {
                chkYellow.Checked = false;
            }
            if (dtOpt.Rows[0]["chkRed"].ToString().ToUpper().Equals("Y"))
            {
                chkRed.Checked = true;
            }
            else
            {
                chkRed.Checked = false;
            }
        }
Пример #18
0
        /// <summary>
        /// 입력 함수
        /// </summary>
        private void efnDeal()
        {
            string strSQL = "";

            // 값이 빈 값이면 리턴
            if (txtPrice.Text == "")
            {
                MessageBox.Show("값을 입력하세요.");
                return;
            }

            //수량 빈 값이면 리턴
            if (txtQuatity.Text == "")
            {
                MessageBox.Show("수량을 입력하세요.");
                return;
            }



            if (cboType.Text == "매수")
            {
                //이름 빈 값이면 리턴
                if (cboStoSearch.Text.Replace(" ", "") == "")
                {
                    MessageBox.Show("종목명을 입력하세요.");
                    return;
                }

                if (mDTHold.Tables[2].Select("Company = '" + cboStoSearch.Text + "'").Length < 1)
                {
                    MessageBox.Show("잘못된 종목입니다.");
                    return;
                }

                else if (mDTHold.Tables[2].Select("Company = '" + cboStoSearch.Text + "'").Length > 1)
                {
                    MessageBox.Show("Code에 중복된 이름의 종목이 있습니다.");
                    return;
                }

                strSQL = @"
                           INSERT INTO Buy (Date, Name, Price, Quantity, Left)
                           VALUES ( '" + dte.Value.ToString("yyyyMMdd") + @"'
                                    , '" + cboStoSearch.Text.ToUpper() + @"'
                                    , '" + txtPrice.Text + @"'
                                    , '" + txtQuatity.Text + @"'
                                    , '" + txtQuatity.Text + @"'
                                  )";
            }

            else if (cboType.Text == "매도")
            {
                //이름 빈 값이면 리턴
                if (cboName.Text.Replace(" ", "") == "")
                {
                    MessageBox.Show("종목명을 입력하세요.");
                    return;
                }

                int       intSellQ;
                int       i = 0;    //반복문변수
                int       intLeftQ; //남은 갯수
                int       intLeftP; //남은 가격
                DataRow[] dr;

                intSellQ = Convert.ToInt32(txtQuatity.Text);

                //이름 체크
                dr = mDTHold.Tables[0].Select("종목명 = '" + cboName.Text.ToUpper() + "'");
                if (dr.Length != 1)
                {
                    MessageBox.Show("해당하는 종목이 매수한 종목에 없습니다.");
                    return;
                }

                if (Convert.ToInt32(dr[0]["수량"].ToString()) < Convert.ToInt32(txtQuatity.Text))
                {
                    MessageBox.Show("매수한 수량보다 많습니다.");
                    return;
                }

                strSQL += @"
                            INSERT INTO Sell (Date, Name, Price, Quantity)
                            VALUES ( '" + dte.Value.ToString("yyyyMMdd") + @"'
                                     , '" + cboName.Text.ToUpper() + @"'
                                     , '" + txtPrice.Text + @"'
                                     , '" + txtQuatity.Text + @"'
                                   );
                         ";

                while (intSellQ > 0)
                {
                    dr       = mDTHold.Tables[1].Select("Left <> 0 AND Name = '" + cboName.Text.ToUpper() + "'", "Seq ASC");
                    intLeftQ = Convert.ToInt32(dr[i]["Left"].ToString());
                    intLeftP = Convert.ToInt32(dr[i]["Price"].ToString());

                    if (intSellQ >= intLeftQ)
                    {
                        strSQL += @"UPDATE Buy
                                       SET Left = 0
                                     WHERE Seq = '" + dr[i]["Seq"].ToString() + @"';
                                   ";

                        strSQL  += @"INSERT INTO Revenue (Date, Name, BPrice, SPrice, Quantity, SellSeq)
                                    VALUES ( '" + dte.Value.ToString("yyyyMMdd") + @"'
                                             , '" + cboName.Text.ToUpper() + @"'
                                             , '" + intLeftP + @"'
                                             , '" + txtPrice.Text + @"'
                                             , '" + intLeftQ + @"'
                                             , CASE WHEN (SELECT COUNT(*) FROM Sell) = 0
                                                    THEN 1
                                                    ELSE (SELECT MAX(Seq) FROM Sell) END
                                           );
                                   ";
                        intSellQ = intSellQ - intLeftQ;
                    }

                    else
                    {
                        strSQL += @"UPDATE Buy
                                       SET Left = " + (intLeftQ - intSellQ) + @"
                                     WHERE Seq = '" + dr[i]["Seq"].ToString() + @"';
                                   ";

                        strSQL += @"INSERT INTO Revenue (Date, Name, BPrice, SPrice, Quantity, SellSeq)
                                    VALUES ( '" + dte.Value.ToString("yyyyMMdd") + @"'
                                             , '" + cboName.Text.ToUpper() + @"'
                                             , '" + intLeftP + @"'
                                             , '" + txtPrice.Text + @"'
                                             , '" + intSellQ + @"'
                                             , CASE WHEN (SELECT COUNT(*) FROM Sell) = 0
                                                    THEN 1
                                                    ELSE (SELECT MAX(Seq) FROM Sell) END
                                            );
                                   ";

                        intSellQ = 0;
                    }

                    i++;
                }
            }

            int iresult = Network.ExecDB(strSQL);

            if (iresult > 0)
            {
                MessageBox.Show("저장되었습니다.");
            }
            else
            {
                MessageBox.Show("저장에 실패하였습니다.");
            }

            txtPrice.Clear();
            cboStoSearch.Text = "";
            txtQuatity.Clear();
        }
        /// <summary>
        /// 디비 저장
        /// </summary>
        /// <param name="p_Seq"></param>
        /// <returns></returns>
        private bool fnSave(int p_Seq)
        {
            if (txtTitle.Text == "")
            {
                MessageBox.Show("제목에 내용이 없습니다.");
                return(false);
            }

            string strSQL     = "";
            string strCboMain = cboMain.Text.Equals("<전체>") ? "" : cboMain.Text;

            if (strCboMain.Replace(" ", "").Equals(""))
            {
                MessageBox.Show("대분류의 내용이 없습니다.");
                return(false);
            }

            //날짜를 바꿨을 경우 파일 경로도 다시 재조정

            if (mIsNew)
            {
                strSQL = @"INSERT INTO Memo ( Date, MainCate, SmallCate, Title, Contents,  Contents_Rtf, Color, Valid, ReportSeq, ReportType)
                            VALUES (
                                     '" + dte.Value.ToString("yyyyMMdd") + @"'
                                    ,'" + strCboMain + @"'
                                    ,'" + cboSmall.Text + @"'
                                    ,'" + txtTitle.Text.Replace("'", "♤") + @"'
                                    ,'" + rtxtContents.Text.Replace("'", "♤") + @"'
                                    ,'" + rtxtContents.Rtf.Replace("'", "♤") + @"'
                                    ,'" + (cboColor.Text == "흰색" ? "" : cboColor.Text) + @"'
                                    ," + "'Y'" + @"
                                    ,'" + mReportSeq + @"'
                                    ,'" + mReportType + @"'
                                    )";
            }
            else
            {
                strSQL = @"UPDATE Memo 
                              SET Date = '" + dte.Value.ToString("yyyyMMdd") + @"', 
                                  MainCate = '" + strCboMain + @"',
                                  SmallCate = '" + cboSmall.Text + @"',
                                  Title = '" + txtTitle.Text.Replace("'", "♤") + @"',
                                  Contents = '" + rtxtContents.Text.Replace("'", "♤") + @"',
                                  Contents_Rtf = '" + rtxtContents.Rtf.Replace("'", "♤") + @"',
                                  Color = '" + (cboColor.Text == "흰색" ? "" : cboColor.Text) + @"'
                            WHERE Seq = " + mSeq;
            }

            try
            {
                int iresult = Network.ExecDB(strSQL);
                if (iresult > 0)
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show("저장실패");
                    return(false);
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return(false);
            }
        }
Пример #20
0
        //관심추가2 버튼 연결
        private void efnAdd2()
        {
            if (btnAdd2.Tag.ToString() == "Add2")
            {
                cboInter.SelectedIndexChanged -= new System.EventHandler(this.cboInter_SelectedIndexChanged);
                cboInter.DropDownStyle         = ComboBoxStyle.Simple;
                cboInter.Text = "";
                fnChangeBtn(btnAdd2.Tag.ToString(), false);
                cboInter.SelectedIndexChanged += new System.EventHandler(this.cboInter_SelectedIndexChanged);
            }
            else if (btnAdd2.Tag.ToString() == "Add2.Comfirm")
            {
                foreach (string itemName in cboInter.Items)
                {
                    if (cboInter.Text == itemName)
                    {
                        MessageBox.Show("같은 이름의 관심목록이 있습니다.");
                        return;
                    }
                }

                if (cboInter.Text.Replace(" ", "") == "")
                {
                    MessageBox.Show("값을 입력해주세요.");
                    return;
                }

                fnInterestSearch();
                string strTempCbo = cboInter.Text;

                cboInter.DropDownStyle = ComboBoxStyle.DropDownList;

                cboInter.Items.Add(strTempCbo);
                cboInter.SelectedIndex = cboInter.Items.IndexOf(strTempCbo);
                fnChangeBtn(btnAdd2.Tag.ToString(), true);
            }

            else if (btnAdd2.Tag.ToString() == "Chg.Comfirm")
            {
                foreach (string itemName in cboInter.Items)
                {
                    if (cboInter.Text == itemName)
                    {
                        MessageBox.Show("같은 이름의 관심목록이 있습니다.");
                        return;
                    }
                }

                if (cboInter.Text.Replace(" ", "") == "")
                {
                    MessageBox.Show("값을 입력해주세요.");
                    return;
                }

                if (Network.ExecDB(@"UPDATE Interest SET InterName = '" + cboInter.Text + @"' WHERE InterName = '" + mInterListName + "'") <= 0)
                {
                    MessageBox.Show("변경 실패");
                    return;
                }

                string strTempCbo = cboInter.Text;

                mfnInterestBinder();

                cboInter.DropDownStyle = ComboBoxStyle.DropDownList;

                //cboInter.Items.Add(strTempCbo);
                cboInter.SelectedIndex = cboInter.Items.IndexOf(strTempCbo);
                fnChangeBtn(btnAdd2.Tag.ToString(), true);
            }
        }