📄 selltable.h
字号:
{
tempSQL = String::Format(S"Delete 销售单明细 where 销售单号 = '{0}'",this->intSellID.ToString());
this->MyDataBase->SQLOperate(tempSQL);
tempSQL = String::Format(S"Delete 销售单 where 编号 = '{0}'",this->intSellID.ToString());
this->MyDataBase->SQLOperate(tempSQL);
this->ds->Clear();
//设置销售单信息
this->tBoxSellDate->Text = S"";
this->tBoxMaker->Text = S"";
this->cmbOperator->Text = S"";
this->tBoxClientID->Text = S"";
this->tBoxClientName->Text = S"";
//查看时不能更改销售单
this->dgrdSellTable->ReadOnly = false;
this->dgrdSellTable->Enabled = false;
this->button1->Enabled = true;
//设置工具栏
this->tbarSave->Enabled = true;
this->tbarDelete->Enabled = false;
}
catch(Exception* e)
{
MessageBox::Show(e->Message,S"提示");
}
}
*/
if(this->ds->Tables->Item[S"销售单明细"]->Rows->Count == 0)
return;
int row = this->dgrdSellTable->CurrentRowIndex;
this->ds->Tables->Item[S"销售单明细"]->Rows->Item[row]->Delete();
}
}
public:
void WareIDDoubleClickHandler(System::Object* sender,EventArgs* e)
{
WareDataManage* tempFrm = new WareDataManage(false);
tempFrm->SetDataGridReadOnly(true);
if(tempFrm->ShowDialog(this) == DialogResult::OK)
{
this->InputWareID = tempFrm->SendWareID;
this->InputWareName = tempFrm->SendWareName;
this->dgrdSellTable->set_Item(this->dgrdSellTable->CurrentCell,this->InputWareID);
this->dgrdSellTable->Select(this->dgrdSellTable->CurrentCell.RowNumber);
}
}
void StorageIDDoubleClickHandler(System::Object* sender,EventArgs* e)
{
this->InputWareID = this->dgrdSellTable->get_Item(this->dgrdSellTable->CurrentCell.RowNumber,2)->ToString();
String* Filter = String::Format("货号 = '{0}'",this->InputWareID);
DataRow* rows[] = this->ds->Tables->Item[S"库存"]->Select(Filter);
if(rows->Length == 0)
{
MessageBox::Show(S"该货物没有库存");
return;
}
SelectStorage* tempFrm = new SelectStorage(this->ds->Tables->Item[S"库存"],this->InputWareID);
tempFrm->nnupImport->Visible = false;
tempFrm->label2->Visible = false;
if(tempFrm->ShowDialog(this) == DialogResult::OK)
{
this->InputStorageName = tempFrm->SendStorageID;
this->InputStorage = tempFrm->SendStorage;
int tempStorage = (int)System::Double::Parse(this->InputStorage->Trim());
int tempExport = (int)System::Double::Parse(tempFrm->Export->Trim());
tempStorage = tempStorage - tempExport;
this->InputStorage = System::Convert::ToString(tempStorage);
int row = this->dgrdSellTable->CurrentCell.RowNumber;
this->dgrdSellTable->set_Item(row,10,this->InputStorageName);
this->dgrdSellTable->set_Item(row,3,__box(tempExport));
//this->ds->Tables->Item[S"销售单明细"]->Rows->Item[row]->set_Item(S"仓库",this->InputStorageName);
//this->ds->Tables->Item[S"销售单明细"]->Rows->Item[row]->set_Item(S"销售数量",__box(tempExport));
//设置库存
String* Filter = String::Format("货号 = '{0}'AND 仓库 = '{1}'",this->InputWareID,this->InputStorageName);
DataRow* StorageRows[] = this->ds->Tables->Item[S"库存"]->Select(Filter);
if(StorageRows->Length > 0)
{
StorageRows[0]->set_Item(S"库存数量",this->InputStorage);
}
}
}
void StorageCheckHandler(System::Object* sender,EventArgs* e)
{
Double SellQuantity;
Double Storage;
//获得销售数量
String* temp = this->dgrdSellTable->get_Item(this->dgrdSellTable->CurrentCell.RowNumber,3)->ToString()->Trim();
//int i = temp->IndexOf(S".");
//temp->Remove(i,temp->Length);
if(temp != System::String::Empty)
SellQuantity = System::Double::Parse(temp);
else
return;
//获得库存
//temp = this->tBoxStorage->Text;
//i = temp->IndexOf(S".");
//temp->Remove(i,temp->Length);
if(temp != System::String::Empty)
Storage = System::Double::Parse(temp);
else
return;
if(SellQuantity > Storage)
{
this->dgrdSellTable->set_Item(this->dgrdSellTable->CurrentCell.RowNumber,3,this->tBoxStorage->Text);
SellQuantity = Storage;
}
}
//显示当前库存
void StorageHandler(System::Object* sender,EventArgs* e)
{
//int SellQuantity = 0;
int Storage = 0;
int row = this->dgrdSellTable->CurrentCell.RowNumber;
this->InputWareID = this->dgrdSellTable->get_Item(this->dgrdSellTable->CurrentCell.RowNumber,2)->ToString();
this->InputStorageName = this->dgrdSellTable->get_Item(this->dgrdSellTable->CurrentCell.RowNumber,10)->ToString();
String* Filter = String::Format("货号 = '{0}'AND 仓库 = '{1}'",this->InputWareID,this->InputStorageName);
DataRow* StorageRows[] = this->ds->Tables->Item[S"库存"]->Select(Filter);
tBoxWareID->Text = this->InputWareID;
if(String::Compare(this->InputStorageName,String::Empty) == 0)
{
tBoxStorage->Text = S"";
}
else if(StorageRows->Length > 0)
{
tBoxStorage->Text = StorageRows[0]->Item[S"库存数量"]->ToString()->Trim();
}
}
private: System::Void dgrdSellTable_Click(System::Object * sender, System::EventArgs * e)
{
}
private: System::Void dgrdSellTable_MouseDown(System::Object * sender, System::Windows::Forms::MouseEventArgs * e)
{
}
//设置客户
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
this->SetClient();
//this->ds->Tables->Item[S"销售单明细"]
}
//更新销售单明细
private: static void UpdateSellDetail(Object* sender, SqlRowUpdatingEventArgs* e)
{
if(e->StatementType != StatementType::Delete)
{
e->Command->Parameters->Item[S"@税价合计"]->Value = e->Row->Item[S"税价合计"]->ToString()->Trim();
e->Command->Parameters->Item[S"@不含税价"]->Value = e->Row->Item[S"不含税价"]->ToString()->Trim();
e->Command->Parameters->Item[S"@税额"]->Value = e->Row->Item[S"税额"]->ToString()->Trim();
}
}
//更新库存
private: static void UpdateStorage(Object* sender, SqlRowUpdatingEventArgs* e)
{
if(e->StatementType == StatementType::Update)
{
e->Command->Parameters->Item[S"@货号"]->Value = e->Row->Item[S"货号"]->ToString()->Trim();
e->Command->Parameters->Item[S"@仓库"]->Value = e->Row->Item[S"仓库"]->ToString()->Trim();
e->Command->Parameters->Item[S"@库存数量"]->Value = e->Row->Item[S"库存数量"]->ToString()->Trim();
}
}
private: System::Void dgrdSellTable_MouseMove(System::Object * sender, System::Windows::Forms::MouseEventArgs * e)
{
//计算总价
Object* obj = this->ds->Tables->Item[0]->Compute(S"SUM(税价合计)",S"");
if(obj != System::DBNull::Value)
{
//如果数据表不为空,则进行计算
String * TotalCount = this->ds->Tables->Item[0]->Compute(S"SUM(税价合计)",S"")->ToString();
String * TotalCountNoTax = this->ds->Tables->Item[0]->Compute(S"SUM(不含税价)",S"")->ToString();
String * TotalTax = this->ds->Tables->Item[0]->Compute(S"SUM(税额)",S"")->ToString();
this->tBoxTotal->Text = TotalCount->ToString();
this->tBoxTotalNoTax->Text = TotalCountNoTax->ToString();
this->tBoxTax->Text = TotalTax->ToString();
}
}
public: void NewSellTable()
{
//清除旧的查询
ds->Tables->Clear();
this->dgrdSellTable->TableStyles->Clear();
String* tempSQL = new String("Select 编号 from 销售单历史");
SqlCommand* sqlCmd = new SqlCommand(tempSQL,this->MyDataBase->myConnection);
SqlDataReader* reader = sqlCmd->ExecuteReader();
//设置新销售单的编号
intSellID = 0;
while(reader->Read())
{
if(intSellID < System::Int32::Parse(reader->Item[0]->ToString()))
intSellID = System::Int32::Parse(reader->Item[0]->ToString());
}
intSellID++;
//设置明细条目的编号
reader->Dispose();
sqlCmd->CommandText = new String("Select 编号 from 销售单明细历史");
reader = sqlCmd->ExecuteReader();
NewDetailID = 0;
while(reader->Read())
{
if(NewDetailID < System::Int32::Parse(reader->Item[0]->ToString()))
NewDetailID = System::Int32::Parse(reader->Item[0]->ToString());
}
NewDetailID++;
reader->Close();
//查询销售单明细
this->strSQL = String::Format("Select * from 销售单明细 where 销售单号 = '{0}'",this->intSellID.ToString());
this->strTableName = S"销售单明细";
this->MyDataBase->SelectDataBase(this->SellDetailAdpater,this->ds,this->strSQL,this->strTableName);
//查询销售单
this->strSQL = String::Format("Select * from 销售单 where 编号 = '{0}'",this->intSellID.ToString());
this->strTableName = S"销售单";
this->MyDataBase->SelectDataBase(this->SellTableAdpater,this->ds,this->strSQL,this->strTableName);
//查询库存
this->strSQL = new String("Select * from 库存库");
this->strTableName = S"库存";
this->MyDataBase->SelectDataBase(this->StorageAdpater,this->ds,this->strSQL,this->strTableName);
//设置数据表
this->DataGridStateControl(true);
this->dgrdSellTable->DataSource = ds->Tables->Item[0];
//新建销售单
DataRow* NewSellTableRow = this->ds->Tables->Item[S"销售单"]->NewRow();
NewSellTableRow->set_Item(S"编号",__box(intSellID));
this->ds->Tables->Item[S"销售单"]->Rows->Add(NewSellTableRow);
//在销售单明细中添加一行
//DataRow* NewSellDetailRow = this->ds->Tables->Item[S"销售单明细"]->NewRow();
//NewSellDetailRow->set_Item(S"销售单号",__box(intSellID));
//this->ds->Tables->Item[S"销售单明细"]->Rows->Add(NewSellDetailRow);
//设置销售单信息
this->SetcmbOperator();
//可以修改销售单
this->dgrdSellTable->ReadOnly = false;
this->dgrdSellTable->Enabled = true;
this->button1->Enabled = true;
//设置工具栏
this->tbarSave->Enabled = true;
this->tbarDelete->Enabled = true;
//设置销售单信息
this->tBoxMaker->Text = S"";
this->cmbOperator->Text = S"";
this->tBoxClientID->Text = S"";
this->tBoxClientName->Text = S"";
this->tBoxTax->Text = S"";
this->tBoxTotalNoTax->Text = S"";
this->tBoxTotal->Text = S"";
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -