// Singleincomemoney.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "Singleincomemoney.h" //#include "InputMemberno.h" #include "SelPayType.h" #include "Login2.h" #include "SelExpendType.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // Singleincomemoney dialog IDC_EDIT3 Singleincomemoney::Singleincomemoney(CWnd* pParent /*=NULL*/) : CDialog(Singleincomemoney::IDD, pParent) { //{{AFX_DATA_INIT(Singleincomemoney) m_money = _T(""); m_time1 = g_date; m_ren2 = g_user.name; m_money1 = _T(""); m_money2 = _T(""); m_money3 = _T(""); m_phone = _T(""); m_sitem = _T(""); m_id = _T(""); m_name = _T(""); //}}AFX_DATA_INIT } void Singleincomemoney::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(Singleincomemoney) DDX_Control(pDX, IDC_LIST1, m_List1); DDX_Control(pDX, IDC_EDIT2, m_editdate1); DDX_Control(pDX, IDC_EDIT1, m_editctrl1); DDX_Text(pDX, IDC_EDIT1, m_money); DDX_Text(pDX, IDC_EDIT2, m_time1); DDX_Text(pDX, IDC_EDITren2, m_ren2); DDX_Text(pDX, IDC_EDITmoney2, m_money1); DDX_Text(pDX, IDC_EDITmoney3, m_money2); DDX_Text(pDX, IDC_EDITmoney5, m_money3); DDX_Text(pDX, IDC_EDITphone, m_phone); DDX_Text(pDX, IDC_EDITsitem, m_sitem); DDX_Text(pDX, IDC_EDITid, m_id); DDX_Text(pDX, IDC_EDITname1, m_name); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(Singleincomemoney, CDialog) //{{AFX_MSG_MAP(Singleincomemoney) ON_WM_LBUTTONDOWN() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_BN_CLICKED(IDC_BUTTON8, OnButton8) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // Singleincomemoney message handlers BOOL Singleincomemoney::OnInitDialog() { CDialog::OnInitDialog(); GetDlgItem(IDC_BUTTON1)->EnableWindow(IsHasRights2new(49)); // if(IsHasRights2new(49)==0)((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly (); // else ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly(); if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115))) m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120;接单点,80"); else m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120"); m_List1.LoadColumnInfo(300); // TODO: Add extra initialization here g_sendhead.bsql = 0; g_sendhead.code[0] = 197; g_sendhead.tabcount = 1; CString filter = "id='" + m_id + "'"; g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0) { CDialog::OnCancel(); return 0; } DataToArray(&m_List1array); CenterWindow(g_pMainWnd); FillGrid(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void Singleincomemoney::OnOK() // 保存按钮 ; { UpdateData(); if (m_money.IsEmpty()) { AfxMessageBox("资料不全!", MB_ICONINFORMATION); return; } if (!CheckDateOK(m_time1))return; CString m_date = m_time1; BOOL bexist1 = 0; BOOL bexist2 = 0; if (bexist1 == 0) { for (int i = 0; i < m_List1array.GetSize(); i++) { if (m_List1array.ElementAt(i).ElementAt(0) == m_money) { bexist1 = 1; break; } } } if (bexist2 == 0) { for (int i = 0; i < m_List1array.GetSize(); i++) { if (m_List1array.ElementAt(i).ElementAt(1) == m_time1) { bexist2 = 1; break; } } } if (bexist1 && bexist2) { if (AfxMessageBox("已有相似的记录, 确认没有重复吗? 是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES) return; } CString sql; CString paytype; SelPayType seltype; seltype.m_paymoney = m_money; if (seltype.DoModal() != IDOK)return; if (seltype.m_radio1 == 0) paytype = "现金"; else if (seltype.m_radio1 == 1) paytype = "POS机刷卡"; else if (seltype.m_radio1 == 2) paytype = "储值卡扣款"; else if (seltype.m_radio1 == 3) paytype = "积分兑换"; else if (seltype.m_radio1 == 4) paytype = "银行转账"; #if JEFF_TEST_ON else if (seltype.m_radio1 == 5) paytype = "代金券"; #endif else if(seltype.m_radio1 == 6) paytype = "支付宝"; else if(seltype.m_radio1 == 7) paytype = "财付通"; else if(seltype.m_radio1 == 8) paytype = "微信支付"; else if(seltype.m_radio1 == 9) paytype = seltype.m_strCustomPayType; #if JEFF_DELETE_ON // old coding; CString jdd; // 接单点; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115))) { SelExpendType dlg; dlg.m_mode = 3; if (dlg.DoModal() == IDOK) jdd = dlg.m_sel; } sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s", m_id, m_money, m_date, m_ren2, paytype, jdd, m_id); CString m_id = "其它二销:" + m_sitem; if (paytype == "储值卡扣款") { if (seltype.m_bChildMoneyCard) { sql += "***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')"; sql += "***refresh balance memberreg4" + seltype.m_parentno + ";" + seltype.m_cardno; } else { sql += "***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')"; sql += "***refresh balance memberreg3"; sql += seltype.m_cardno; } } else if (paytype == "积分兑换") { CString point; float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0; point.Format("%d", (int)(atof(m_money)*GetPointScale2() / rate)); sql += "***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + point + "','" + g_date + "')"; sql += "***refresh balance memberreg2"; sql += seltype.m_cardno; } g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); // CDialog::OnOK(); #else CString strBranchName = seltype.m_branch; // 当前选择的分店名; CString strOurBranchName = GetNameFromDomain(g_domain); // 本店店名; // 无分店,非集团版; // 选择的分店与连接的分店相同; // 连接的分店空且分店名与本店名相同; // 使用集团版,但只有一家店; // 使用的数据和要保存的数据都属于一家分店的情况; if ( strBranchName == _T("") || strBranchName == g_branchname || (g_branchname == "" && strBranchName == strOurBranchName)) { CString jdd; // 接单点; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115))) { SelExpendType dlg; dlg.m_mode = 3; if (dlg.DoModal() == IDOK) jdd = dlg.m_sel; } sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s", m_id, m_money, m_date, m_ren2, paytype, jdd, m_id); CString m_id = "其它二销:" + m_sitem; if (paytype == "储值卡扣款") { if (seltype.m_bChildMoneyCard) { sql += "***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')"; sql += "***refresh balance memberreg4" + seltype.m_parentno + ";" + seltype.m_cardno; } else { sql += "***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')"; sql += "***refresh balance memberreg3"; sql += seltype.m_cardno; } // 其他消费短信; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // 122=msgcheck16 { CString content, timestamp; CString m_phone = seltype.m_phone;; content.Format("%s您好,您本次使用现金卡消费%s元,余额:%d元", seltype.m_name, m_money, seltype.m_money - atoi(m_money)); timestamp = "msgtimestamp"; if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0)) { int count = GetLengthEx(content) / MSG_LENGTH; if (GetLengthEx(content) % MSG_LENGTH) count++; CString scount; scount.Format("%d", count); CString sql2 = _T(""); sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送")); sql += _T("***"); sql += _T("***") + sql2; } } } else if (paytype == "积分兑换") { CString point; float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0; point.Format("%d", (int)(atof(m_money)*GetPointScale2() / rate)); sql += "***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + point + "','" + g_date + "')"; sql += "***refresh balance memberreg2"; sql += seltype.m_cardno; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // msgcheck16 { CString content, timestamp; CString m_phone = seltype.m_phone;; float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0; int point = (int)(atof(m_money) / rate + 0.5); content.Format("%s您好,您本次使用积分%d分,余额:%d分", seltype.m_name, point, seltype.m_point - point); timestamp = "msgtimestamp"; if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0)) { int count = GetLengthEx(content) / MSG_LENGTH; if (GetLengthEx(content) % MSG_LENGTH) count++; CString scount; scount.Format("%d", count); CString sql2 = _T(""); sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送")); sql += _T("***"); sql += _T("***") + sql2; } } } g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); } else { CString sql3; BOOL bBranchModifyBak = g_bBranchModify; CString strbranchnameBak = g_branchname; CString strbranchipBak = g_branchip; CString strCurbranch; if (g_branchname != "") strCurbranch = g_branchname; else strCurbranch = strOurBranchName; // 逻辑问题:这里不能显示接单点与id组合的字符串,因为表singleincome的是自增id; //CString m_id2 = strCurbranch + m_id; CString jdd; // 接单点; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115))) { SelExpendType dlg; dlg.m_mode = 3; if (dlg.DoModal() == IDOK) jdd = dlg.m_sel; } sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s", m_id, m_money, m_date, m_ren2, paytype, jdd, m_id); CString strSQL = _T(""); CString id = strCurbranch + _T("其它二销:") + m_sitem; if (paytype == "储值卡扣款") { if (seltype.m_bChildMoneyCard) { strSQL += "***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + id + "','" + m_money + "','" + m_date + "')"; strSQL += "***refresh balance memberreg4" + seltype.m_parentno + ";" + seltype.m_cardno; } else { strSQL += "***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + id + "','" + m_money + "','" + m_date + "')"; strSQL += "***refresh balance memberreg3"; strSQL += seltype.m_cardno; } // 其他消费短信; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // 122=msgcheck16 { CString content, timestamp; CString m_phone = seltype.m_phone;; content.Format("%s您好,您本次使用现金卡消费%s元,余额:%d元", seltype.m_name, m_money, seltype.m_money - atoi(m_money)); timestamp = "msgtimestamp"; if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0)) { int count = GetLengthEx(content) / MSG_LENGTH; if (GetLengthEx(content) % MSG_LENGTH) count++; CString scount; scount.Format("%d", count); CString sql2 = _T(""); sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送")); strSQL += _T("***"); strSQL += _T("***") + sql2; } } } else if (paytype == "积分兑换") { CString point; float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0; point.Format("%d", (int)(atof(m_money)*GetPointScale2() / rate)); strSQL += "***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + point + "','" + g_date + "')"; strSQL += "***refresh balance memberreg2"; strSQL += seltype.m_cardno; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // msgcheck16 { CString content, timestamp; CString m_phone = seltype.m_phone;; float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0; int point = (int)(atof(m_money) / rate + 0.5); content.Format("%s您好,您本次使用积分%d分,余额:%d分", seltype.m_name, point, seltype.m_point - point); timestamp = "msgtimestamp"; if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0)) { int count = GetLengthEx(content) / MSG_LENGTH; if (GetLengthEx(content) % MSG_LENGTH) count++; CString scount; scount.Format("%d", count); CString sql2 = _T(""); sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送")); strSQL += _T("***"); strSQL += _T("***") + sql2; } } } // 断开软件选择的分店连接,获取选择的接单点分店ip; // 连接接单点分店并写入数据到接单点数据库; g_pMainWnd->OnDisconnect(); g_branchip = GetIP(strBranchName); g_pMainWnd->OnDisconnect(); g_branchname = strBranchName; g_bBranchModify = 1; g_sendhead.bsql = 1; strSQL.TrimLeft("***"); g_pMainWnd->ProcessChatMessageRequest2(strSQL); if (g_bSendOK == 0)return; // 恢复软件选择的分店连接; // 并写入数据; g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = ""; g_bBranchModify = bBranchModifyBak; g_branchname = strbranchnameBak; g_branchip = strbranchipBak; g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); } #endif } HBRUSH Singleincomemoney::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if (nCtlColor == CTLCOLOR_STATIC) { pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明 return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色 } // TODO: Return a different brush if the default is not desired return hbr; } void Singleincomemoney::OnLButtonDown(UINT nFlags, CPoint point) { CDialog::OnLButtonDown(nFlags, point); } void Singleincomemoney::GetData() { g_sendhead.bsql = 0; g_sendhead.code[0] = 197; g_sendhead.tabcount = 1; CString filter = "id='" + m_id + "'"; g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return; DataToArray(&m_List1array); FillGrid(); float payed = 0; for (int i = 0; i < m_List1.GetItemCount(); i++) { payed += atof(m_List1.GetItemText(i, 1)); } m_money2.Format("%0.1f", payed); m_money3.Format("%0.1f", atof(m_money1) - atof(m_money2)); UpdateData(0); } void Singleincomemoney::FillGrid() { m_List1.DeleteAllItems2(); int ii = 0; m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1); int count = 0; for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); } m_List1.m_arLabels.SetSize(count, 1); ii = count; m_List1.m_LabelCount = ii; m_List1.SetItemCountEx(ii); } BOOL Singleincomemoney::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { switch (pMsg->wParam) { case VK_RETURN: return 1; } } return CDialog::PreTranslateMessage(pMsg); } void Singleincomemoney::OnButton1() // 删除按钮; { if (IsHasRights2new(49) == 0)return; POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) { AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION); return; } if (AfxMessageBox("是否删除此项目?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return; int iItem = m_List1.GetNextSelectedItem(pos); CString id = m_List1.GetItemText(iItem, 0); CString money = m_List1.GetItemText(iItem, 1); CString bz = m_List1.GetItemText(iItem, 2) + m_List1.GetItemText(iItem, 3); CString sql; sql.Format("delete from singleincomemoney where [autoid]=%d***refresh singleincomemoney%s", atol(id), m_id); g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; GetData(); CString str; str = m_List1.GetItemText(iItem, 3); str += "删除客人"; str += m_name; str += m_List1.GetItemText(iItem, 2); str += "其它二销收款:"; str += money; WriteLog(_T("其它二销"), str); } void Singleincomemoney::OnButton3() // 更改按钮; { // TODO: Add your control notification handler code here Login2 dlg; dlg.m_mode = 3; if (dlg.DoModal() != IDOK)return; if (IsHasRightsnew2(49, dlg.m_rights) == 0)return; ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly(0); } void Singleincomemoney::OnButton8() // 打单按钮; { // TODO: Add your control notification handler code here //AfxMessageBox("789"); POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) { AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION); return; } int iItem; CStringArray array; array.Add(""); array.Add(g_cominfoarray.ElementAt(0).ElementAt(48)); array.Add("NO." + m_id); CString str = "地址:" + g_cominfoarray.ElementAt(0).ElementAt(12); str += " 电话:" + g_cominfoarray.ElementAt(0).ElementAt(11); array.Add(str); CString name = m_name; CString phone = m_phone; array.Add("客户姓名:" + name); if (IsHasRights2new(31) == 0) array.Add(""); else array.Add("联系电话:" + phone); CString date; date.Format("日期:%s年%s月%s日", g_date.Mid(0, 4), g_date.Mid(5, 2), g_date.Mid(8, 2)); array.Add(date); array.Add(" 收 款 项 目 "); // Jeff 显示打印支付方式; int isSmall = atoi(g_cominfoarray.ElementAt(0).ElementAt(87));//小单 if(isSmall == 0) array.Add(" 支付方式 "); array.Add(" 金 额 "); array.Add(" 开单人 "); int count = 0; float money = 0; while (pos) { count++; if (m_bz != "" && count > 3)break; if (count > 4)break; iItem = m_List1.GetNextSelectedItem(pos); array.Add(m_sitem); // 显示打印支付方式; if(isSmall == 0) array.Add(m_List1.GetItemText(iItem, 4)); // add by Jeff:添加支付方式; array.Add(m_List1.GetItemText(iItem, 1)); money += atof(m_List1.GetItemText(iItem, 1)); array.Add(m_ren); } if (m_bz != "" && count == 1) { array.Add(""); array.Add(""); array.Add(""); array.Add(""); array.Add(""); array.Add(""); array.Add(""); array.Add(""); array.Add(m_bz); array.Add(""); array.Add(""); array.Add(""); } if (m_bz != "" && count == 2) { array.Add(""); array.Add(""); array.Add(""); array.Add(""); array.Add(m_bz); array.Add(""); array.Add(""); array.Add(""); } if (m_bz != "" && count == 3) { array.Add(m_bz); array.Add(""); array.Add(""); array.Add(""); } if (m_bz != "" && count == 4) { array.Add(m_bz); array.Add(""); array.Add(""); array.Add(""); } //while(array.GetSize ()<22) array.Add (""); while (array.GetSize() < 27) array.Add(""); // 显示打印支付方式; CString smoney; smoney.Format("%0.1f", money); if(isSmall == 0)//小单 { str = "付款情况 应付:" + m_money1; str += " 实付:" + m_money2; str += " 欠款:" + m_money3; } else { str = "付款情况 应付:" + m_money1; str += " 实付:" + m_money2; str += " 欠款:" + m_money3; } array.Add(str); if(isSmall == 0)//小单 { str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \ GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney))); } else { str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \ GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney))); } array.Add(str); array.Add(g_cominfoarray.ElementAt(0).ElementAt(120)); array.Add(" 收银:" + g_user.name); array.Add("顾客签名:"); array.Add("");//第\r\n一\r\n联\r\n存\r\n根\r\n∧\r\n白\r\n∨\r\n第\r\n二\r\n联\r\n财\r\n务\r\n∧\r\n黄\r\n∨\r\n第\r\n三\r\n联\r\n客\r\n户\r\n∧\r\n红\r\n∨"); g_pMainWnd->PrintReceipt_02(&array); // 2销收入,应该使用PrintReceipt_01,需要显示支付方式 Jeff } /* insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype]) select [id],[money],[dat],[renyuan2],[paytype] from singleincome where payed is null***update [singleincome] set [payed]=(select sum(cast(money as float)) from [singleincomemoney] where [singleincome].[id]=[singleincomemoney].[id])***update [singleincome] set [balance]=cast(money as float)-cast(payed as float) */