コード例 #1
0
void SettingsNotebook::LoadPageData(int page, InformData *data)
{
  if(data!=NULL) source=(SourceFile *) data;
  if(source==NULL) return;
  if(page==-1) page=GetSelection();

  switch(page) {
  case 0:
    SetEdit(editStory, INF_STORY, source, true, false);
    SetEdit(editHeadline, INF_HEADLINE, source, true, false);
    SetEdit(editIntroduction, INF_INITDESC, source, true, false);
    SetComboLocation(comboStart, source, true);
    break;
  }
}
コード例 #2
0
void PharmacyReceipt::on_addButton_clicked()
{
	SetEdit(true);
	ui.saveButton->setEnabled(true);
	ui.discardButton->setEnabled(true);
	ui.editButton->setEnabled(false);
	ui.deleteButton->setEnabled(false);
	ui.addRowButton->setEnabled(true);
	ui.deleteRowButton->setEnabled(true);
	ui.tableWidget->setRowCount(0);
	ui.tableWidget->clearContents();
	ui.tableWidget->insertRow(0);
	iRow = 0;
	icount = 0;
	ui.tableWidget->setEditTriggers(QAbstractItemView::DoubleClicked);
	int rows = ui.tableWidget->model()->rowCount();   //行总数
	for (int i=0;i<rows;i++)
	{
		if(i!=0)
			ui.tableWidget->removeRow(i);
	}
	int isheetcount=PublicInfoSheetNo();
	isheetcount++;
	QString strSheetNo= "DBSH"+QString::number(isheetcount, 10);
	ui.lineEdit_No->setText(strSheetNo);
	ui.lineEdit_Payable->setText("0");
	ui.lineEdit_Paid->setText("0");
	ui.lineEdit_Debt->setText("0");
}
コード例 #3
0
ファイル: drugstorage.cpp プロジェクト: wangfeilong321/his
void DrugStorage::on_addButton_clicked()
{
    initUI();
    SetEdit(true);
    ui.saveButton->setEnabled(true);
    ui.discardButton->setEnabled(true);
    ui.addRowButton->setEnabled(true);
    ui.deleteRowButton->setEnabled(true);
    ui.editButton->setEnabled(false);
    ui.deleteButton->setEnabled(false);
    ui.tableWidget->setRowCount(0);
    ui.tableWidget->clearContents();
    ui.tableWidget->insertRow(0);
    ui.tableWidget->setEditTriggers(QAbstractItemView::DoubleClicked);
    iRow = 0;
    icount = 0;
    ui.tableWidget->setRowCount(0);
    ui.tableWidget->clearContents();
    ui.tableWidget->insertRow(0);
    int isheetcount=PublicInfoSheetNo();
    isheetcount++;
    QString strSheetNo= "YPRK"+QString::number(isheetcount, 10);
    ui.lineEdit_No->setText(strSheetNo);
    ui.lineEdit_Payable->setText("0");
    ui.lineEdit_Paid->setText("0");
    ui.lineEdit_debt->setText("0");
}
コード例 #4
0
ファイル: drugstorage.cpp プロジェクト: wangfeilong321/his
void DrugStorage::edit(QString strNo)
{
    ui.tableWidget->installEventFilter(this);
    SetEdit(false);
    ui.addButton->setEnabled(false);
    ui.editButton->setEnabled(true);
    QSqlQuery query(*sql.db);
    query.exec("select * from yk_instorage where sheetno='"+strNo+"'");
    while(query.next())
    {
        ui.lineEdit_No->setText(query.value(1).toString());
        ui.dateTimeEdit->setDateTime(query.value(2).toDateTime());
        int iInputFlag=query.value(3).toString().toInt();
        if(iInputFlag == 1)
            ui.radioButton_Add->setChecked(true);
        else
            ui.radioButton_Minus->setChecked(true);

        ui.comboBox_supplier->setEditText(query.value(5).toString());
        ui.lineEdit_2->setText(query.value(6).toString());
    }
    ui.tableWidget->setRowCount(0);
    QSqlQuery query2(*sql.db);
    query2.exec("select * from yk_instorage where sheetno='"+strNo+"'");
    int row= 0;
    while(query2.next())
    {
        int Num;
        ui.tableWidget->insertRow(row);
        ui.tableWidget->setItem(row,1,new QTableWidgetItem(query2.value(4).toString()));
        QString strName=query2.value(8).toString();
        QString strsql= "select * from sys_drugdictionary where name='"+strName+"'";
        query.exec(strsql);
        while(query.next())
        {
            ui.tableWidget->setItem(row,1,new QTableWidgetItem(query.value(1).toString()));
            ui.tableWidget->setItem(row,2,new QTableWidgetItem(query.value(4).toString()));
            ui.tableWidget->setItem(row,3,new QTableWidgetItem(query.value(5).toString()));
            ui.tableWidget->setItem(row,5,new QTableWidgetItem(query.value(6).toString()));
            ui.tableWidget->setItem(row,8,new QTableWidgetItem(query.value(15).toString()));
            ui.tableWidget->setItem(row,9,new QTableWidgetItem(query.value(16).toString()));//
            ui.tableWidget->setItem(row,10,new QTableWidgetItem(query.value(10).toString()));//
            //Num = query.value(10).toString().toInt();
        }
        Num = query2.value(13).toString().toInt();

        strsql= "select * from yk_inventory where name='"+strName+"'";
        query.exec(strsql);
        if(query.next())
        {
            int kucun1 = query.value(7).toString().toInt();
            kucun1 = kucun1 - Num;
            QString strTemp = QString::number(kucun1);
            ui.tableWidget->setItem(row,7,new QTableWidgetItem(strTemp));  //有问题
        }
        ui.tableWidget->setItem(row,6,new QTableWidgetItem(query2.value(13).toString()));
        row++;
    }
}
コード例 #5
0
void PharmacyReceipt::on_editButton_clicked()
{
	SetEdit(true);
	ui.deleteButton->setEnabled(true);
	ui.saveButton->setEnabled(true);
	ui.discardButton->setEnabled(true);
	ui.addRowButton->setEnabled(true);
	ui.deleteRowButton->setEnabled(true);
}
コード例 #6
0
ファイル: drugcheck.cpp プロジェクト: wangfeilong321/his
void DrugCheck::on_editButton_clicked()
{
	SetEdit(true);
	ui.deleteButton->setEnabled(true);
	ui.saveButton->setEnabled(true);
	ui.discardButton->setEnabled(true);
	ui.addRowButton->setEnabled(true);
	ui.deleteRowButton->setEnabled(true);
}
コード例 #7
0
ファイル: drugcheck.cpp プロジェクト: wangfeilong321/his
void DrugCheck::edit(QString strNo)
{
	ui.tableWidget->installEventFilter(this);
	SetEdit(false);
	ui.addButton->setEnabled(false);
	ui.editButton->setEnabled(true);
	QSqlQuery query(*sql.db);	
	query.exec("select * from yk_check where sheetno='"+strNo+"'");
	while(query.next())
	{
		ui.lineEdit_CheckNo->setText(query.value(1).toString());
		ui.dateTimeEdit->setDateTime(query.value(2).toDateTime());
		
		ui.lineEdit_Remark->setText(query.value(4).toString());		
	}
	ui.tableWidget->setRowCount(0);
	QSqlQuery query2(*sql.db);	
	query2.exec("select * from yk_check where sheetno='"+strNo+"'");
	int row= 0;
	while(query2.next())
	{
		int Num;
		ui.tableWidget->insertRow(row);
		//ui.tableWidget->setItem(row,1,new QTableWidgetItem(query2.value(4).toString()));
		QString strName=query2.value(6).toString();
		QString strsql= "select * from sys_drugdictionary where name='"+strName+"'";
		query.exec(strsql);
		while(query.next())
		{
			ui.tableWidget->setItem(row,1,new QTableWidgetItem(query.value(1).toString()));
			ui.tableWidget->setItem(row,2,new QTableWidgetItem(query.value(4).toString()));
			ui.tableWidget->setItem(row,3,new QTableWidgetItem(query.value(5).toString()));
			ui.tableWidget->setItem(row,5,new QTableWidgetItem(query.value(6).toString()));
			
			ui.tableWidget->setItem(row,9,new QTableWidgetItem(query.value(15).toString()));//
			//Num = query.value(10).toString().toInt();
		}
		ui.tableWidget->setItem(row,6,new QTableWidgetItem(query2.value(12).toString()));
		ui.tableWidget->setItem(row,7,new QTableWidgetItem(query2.value(13).toString()));//
		//strsql= "select * from yk_inventory where name='"+strName+"'";
		//query.exec(strsql);
		//if(query.next())
		//{
		//	int kucun1 = query2.value(7).toString().toInt();
		//	kucun1 = kucun1 - Num;
		//	QString strTemp = QString::number(kucun1);
		//	ui.tableWidget->setItem(row,7,new QTableWidgetItem(strTemp));  //有问题
		//}
		//ui.tableWidget->setItem(row,6,new QTableWidgetItem(query2.value(13).toString()));
		row++;
	}
}
コード例 #8
0
ファイル: drugcheck.cpp プロジェクト: wangfeilong321/his
void DrugCheck::on_addButton_clicked()
{
	SetEdit(true);
	ui.saveButton->setEnabled(true);
	ui.discardButton->setEnabled(true);
	ui.editButton->setEnabled(false);
	ui.deleteButton->setEnabled(false);
	ui.addRowButton->setEnabled(true);
	ui.deleteRowButton->setEnabled(true);
	ui.tableWidget->setRowCount(0);
	ui.tableWidget->clearContents();
	ui.tableWidget->insertRow(0);
	iRow = 0;
	icount = 0;

	int isheetcount=PublicInfoSheetNo();
	isheetcount++;
	QString strSheetNo= "YPPC"+QString::number(isheetcount, 10);
	ui.lineEdit_CheckNo->setText(strSheetNo);
	ui.lineEdit_PreProfit->setText("0");
	ui.lineEdit_CurProfit->setText("0");
	ui.lineEdit_AftProfit->setText("0");

}
コード例 #9
0
ファイル: Lab4.cpp プロジェクト: ThunderHawks/The-Hook
int main( int argc, char *argv[] )
{
    GLFWwindow *window;
    int Edit;
    //File name to load
    string fileName;
    //whether name inputtted is valid
    bool validFile = false;

    //Try to determine file input
    while(validFile == false) {
        printf("Type the file to load (Special options: 'd' = default, 'c' = clean):\n");
        scanf("%s", &fileName[0]);

        ifstream toLoad(&fileName[0]);
        validFile = toLoad.good();

        //If 'c' was entered, then load a clean level
        if(strcmp(&fileName[0], "c") == 0) {
            printf("Loading clean level...\n");
            fileName = "clean";
            validFile = true;
        }
        //If 'd' was entered, then deafult level
        else if(strcmp(&fileName[0], "d") == 0) {
            printf("Loading default level...\n");
            fileName = "default";
            validFile = true;
        }
        else if(validFile == false) {
            printf("Bad file, please type another file to load.\n");
        }
        else if(validFile == true) {
            toLoad.close();
        }
    }

    //Determine mode
    printf("Type 0 to play, any other int to edit\n");
    scanf("%i", &Edit);

    glfwSetErrorCallback(glfwError);
    if (!glfwInit()) {
        exit(EXIT_FAILURE);
    }

    //If Edit Mode
    if(Edit) {
        //World Edit Init
        //initWorldEdit(window);
        window = glfwCreateWindow(800, 800, "World Editor", NULL, NULL);
        if (!window) {
            glfwTerminate();
            exit(EXIT_FAILURE);
        }
        srand(time(0));
        glfwMakeContextCurrent(window);
        glfwSetWindowPos(window, 80, 80);
        glfwSetWindowSizeCallback(window, glfwWindowResize);
        glfwSetWindowSize(window,1600,800);
        g_height =800;
        g_width = 1600;
        setDistance(7);
        SetEdit(1);
        paused = false;

        glfwSetKeyCallback( window, glfwEditKeyPress);
        glfwSetCursorPosCallback( window, glfwEditGetCursorPos );
        glfwSetMouseButtonCallback( window, glfwEditMouse );
        glfwSetScrollCallback( window, glfwEditScroll );

        glewInit();
        glInitialize(window);
        physicsInit();
        InitGeom();
        initLevelLoader();
        loadLevel(fileName);
    }
    //If Play Mode
    else {
        //Game Play Init
        //initGamePlay(window);
        window = glfwCreateWindow(800, 800, "Grapple", NULL, NULL);
        if (!window) {
            glfwTerminate();
            exit(EXIT_FAILURE);
        }
        srand(time(0));
        SetEye(vec3(0, 0, 0));
        glfwMakeContextCurrent(window);
        glfwSetWindowPos(window, 80, 80);
        glfwSetWindowSizeCallback(window, glfwWindowResize);
        glfwSetWindowSize(window,1600,800);
        g_height =800;
        g_width = 1600;
        setDistance(10);
        paused = false;

        glfwSetKeyCallback(window, glfwGameKeyPress);
        glfwSetCursorPosCallback( window, glfwGameGetCursorPos );

        glewInit();
        glInitialize(window);
        physicsInit();
        InitGeom();
        initLevelLoader();
        loadLevel(fileName);
    }

    ShadowMap *shadowMap = new ShadowMap();
    if (shadowMap->MakeShadowMap(g_width, g_height) == -1) {
        printf("SHADOW MAP FAILED\n");
        exit(EXIT_FAILURE);
    }

    // Start the main execution loop.
    while (!glfwWindowShouldClose(window)) {
        glfwPollEvents();
        if(Edit) {
            if(paused == false) {
                //Keep the cursor centered
                glfwSetCursorPos(window,g_width/2,g_height/2);
                renderScene(window, shadowMap);
                glfwEditGetCursorPos(NULL,g_width/2.0,g_height/2.0);
                //glfw Game Keyboard
                glfwEditKeyboard();
            }
        }
        else {
            if(paused == false) {
                //player appy physics controls
                SetLookAt(glm::vec3(physGetPlayerX(),physGetPlayerY(),physGetPlayerZ()));
                SetSpeed(.05*magnitude(getPlayerSpeed()));
                //Keep the cursor centered
                glfwSetCursorPos(window,g_width/2,g_height/2);
                physStep();
                //Draw stuff
                renderScene(window, shadowMap);
                glfwGameGetCursorPos(NULL,g_width/2.0,g_height/2.0);
                //glfw Game Keyboard
                glfwGameKeyboard();
            }
        }
        usleep(15000);
    }

    // Clean up after GLFW.
    glfwDestroyWindow(window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #10
0
void PharmacyReceipt::on_saveButton_clicked()
{
	static int iFlag;
	int i=0;
	int amount;
	double unitprice;
	int rows = ui.tableWidget->model()->rowCount();   //行总数
	QString str2;
	QString str = str.fromLocal8Bit("警告");
	char strtemp[255]={0};
	unitprice = ui.lineEdit_Debt->text().toDouble();

	//if(unitprice<0)
	//{
	//	if(ui.radioButton_Add->isChecked())
	//	    str2 = str.fromLocal8Bit("付款金额不足,请核对!");
	//	if(ui.radioButton_Minus->isChecked())
	//		str2 = str.fromLocal8Bit("收款金额不足,请核对!");
	//	QMessageBox::warning(this,str,str2,QMessageBox::Ok);
	//	return;
	//}

	if(!ui.tableWidget->isEnabled())
	{	
		str2 = str.fromLocal8Bit("已保存过!");		
		QMessageBox::warning(this,str,str2,QMessageBox::Ok);
		return;
	}


	//QSqlQuery query(*sql.db);		
	//QString strSheetNo=ui.lineEdit_No->text();
	//QString strsql = "select * from yf_receipt where sheetno ='"+strSheetNo+"'"; //where ID > 1
	//query.exec(strsql);
	//if(query.next())
	//{
	//	strsql = "delete from yf_receipt where sheetno ='"+strSheetNo+"'"; //where ID > 1
	//	query.exec(strsql);
	//}
	QSqlQuery query(*sql.db);		
	QString strSheetNo=ui.lineEdit_No->text();
	QString strsql = "select * from yf_receipt where sheetno ='"+strSheetNo+"'"; //where ID > 1
	query.exec(strsql);
	int num = 0;
	int inputflag;
	QStringList list;
	int kucun2;
	while(query.next())
	{
		QString strTemp = query.value(6).toString();
		list.append(strTemp);
		num++;
	}
	
	for(i=0;i<num;i++)
	{
		QString strName = list[i];
		strsql = "select * from yf_receipt where sheetno ='"+strSheetNo+"'and name ='"+strName+"'"; //where ID > 1
		query.exec(strsql);
		if(query.next())
		{
			amount = query.value(11).toInt();	
			inputflag = query.value(3).toInt();
		}
		strsql= "select * from yf_inventory where name ='"+strName+"'";//;//where AbbrName = '"+strName+"'
		query.exec(strsql);
		int kucun =0;
		if(query.next())
			kucun = query.value(7).toInt();	
		if(inputflag == 1)
		kucun2 = kucun - amount;
		if(inputflag == 2)
		kucun2 = kucun + amount;
		query.prepare("UPDATE yf_inventory SET count= ? WHERE name = '"+strName+"'");
		query.bindValue(0,kucun2);
		QString strTemp1 = QString::number(kucun2);
		ui.tableWidget->setItem(i,7,new QTableWidgetItem(strTemp1));
		query.exec();	
	}
	if(num>0)
	{
		strsql = "delete from yf_receipt where sheetno ='"+strSheetNo+"'"; //where ID > 1
		query.exec(strsql);
		strsql = "delete from yf_receipt_public_info where sheetno ='"+strSheetNo+"'"; //where ID > 1
		query.exec(strsql);
	}
	
	int isheetcount=PublicInfoSheetNo();
		isheetcount++;
	query.prepare("INSERT INTO yf_receipt_public_info VALUES (?, ?, ?, ?, ?)");
	query.bindValue(0, isheetcount);
	query.bindValue(1, ui.lineEdit_No->text());
	query.bindValue(2, ui.dateTimeEdit->dateTime());
	int iInputFlag;
	if(ui.radioButton_Add->isChecked())
		iInputFlag = 1;
	if(ui.radioButton_Minus->isChecked())
		iInputFlag = 2;
	//if(ui.radioButton_sendback->isChecked())
	//	iInputFlag = 3;
	//if(ui.radioButton_broken->isChecked())
	//	iInputFlag = 4;
	QString strTemp = QString::number(iInputFlag);
	query.bindValue(3, strTemp);
	query.bindValue(4, ui.lineEdit_remark->text());
	iFlag = query.exec();

	for (i=0;i< rows ;i++)
	{
		if(ui.tableWidget->item(i,6)==NULL||(ui.tableWidget->item(i,6)&& ui.tableWidget->item(i,6)->text()==tr("")))
		{
			sprintf(strtemp,"第%d行收货数量为空,请核对!",i+1);
			str2 = str.fromLocal8Bit(strtemp);		
			QMessageBox::warning(this,str,str2,QMessageBox::Ok);
			return;
		}
		isheetcount=SheetNo();
		isheetcount++;
		query.prepare("INSERT INTO yf_receipt VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
		query.bindValue(0, isheetcount);
		query.bindValue(1, ui.lineEdit_No->text());
		query.bindValue(2, ui.dateTimeEdit->dateTime());
		int iInputFlag;
		if(ui.radioButton_Add->isChecked())
			iInputFlag = 1;
		if(ui.radioButton_Minus->isChecked())
			iInputFlag = 2;
		//if(ui.radioButton_sendback->isChecked())
		//	iInputFlag = 3;
		//if(ui.radioButton_broken->isChecked())
		//	iInputFlag = 4;
		QString strTemp = QString::number(iInputFlag);
		query.bindValue(3, strTemp);
		query.bindValue(4, ui.lineEdit_remark->text());
		query.bindValue(5, ui.tableWidget->item(i,0)->text());
		query.bindValue(6, ui.tableWidget->item(i,1)->text());
		query.bindValue(7, ui.tableWidget->item(i,2)->text());
		query.bindValue(8, ui.tableWidget->item(i,3)->text());
		query.bindValue(10, ui.tableWidget->item(i,5)->text());//单位
		//query.bindValue(11, ui.tableWidget->item(i,6)->text());//数量
		//query.bindValue(12, ui.tableWidget->item(i,8)->text());//单价


		//if(ui.radioButton_Add->isChecked())
		//{
		//	amount = ui.tableWidget->item(i,6)->text().toInt();
		//	unitprice = ui.tableWidget->item(i,8)->text().toDouble();
		//}
		//if(ui.radioButton_Minus->isChecked())
		//{
		//	amount = -ui.tableWidget->item(i,6)->text().toInt();
		//	unitprice = -ui.tableWidget->item(i,8)->text().toDouble();
		//}

		amount = ui.tableWidget->item(i,6)->text().toInt();
		unitprice = ui.tableWidget->item(i,8)->text().toDouble();

		//if(ui.radioButton_broken->isChecked())
		//{
		//	amount = -ui.tableWidget->item(i,6)->text().toInt();
		//	unitprice =0;// -ui.tableWidget->item(i,8)->text().toDouble();
		//}

		query.bindValue(11, amount);
		query.bindValue(12, unitprice);
		unitprice = unitprice * amount;
		/*QString strprice= QString::number(unitprice);*/
		query.bindValue(13,unitprice);
		
		iFlag = query.exec();
	//}
	
	//for (i=0;i< rows ;i++)
	//{	
		QString strName = ui.tableWidget->item(i,1)->text();	
		int kucun = ui.tableWidget->item(i,7)->text().toInt();
		int kucun1=0;
			//kucun1 = kucun + amount;

		if(ui.radioButton_Add->isChecked())
		{
			kucun1 = kucun + amount;
		}
		if(ui.radioButton_Minus->isChecked())
		{
			kucun1 = kucun - amount;
		}
		kucun = kucun1;
		QString strTemp1 = QString::number(kucun1);
		ui.tableWidget->setItem(i,7,new QTableWidgetItem(strTemp1));

		QString strsql= "select * from yf_inventory where name ='"+strName+"'";//;//where AbbrName = '"+strName+"'
		query.exec(strsql);

		if(query.next())
		{
			query.prepare("UPDATE yf_inventory SET count= ? WHERE name = '"+strName+"'");
			query.bindValue(0,kucun1);
			iFlag = query.exec();
		}
		else
		{
			query.prepare("INSERT INTO yf_inventory VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
			isheetcount=InventorySheetNo();
			isheetcount ++;
			query.bindValue(0, isheetcount);
			query.bindValue(1, strName);
			query.bindValue(2, strName);
			query.bindValue(3, ui.tableWidget->item(i,2)->text());
			query.bindValue(4, ui.tableWidget->item(i,3)->text());
			query.bindValue(6, ui.tableWidget->item(i,5)->text());
			query.bindValue(7, strTemp1);
			iFlag = query.exec();
			
		}
	}

		
	if(iFlag)
	{
		QString str = str.fromLocal8Bit("提示");
		QString str2 = str.fromLocal8Bit("保存成功!");
	//	QMessageBox::information(this,str,str2);
		//ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
		SetEdit(false);
		ui.saveButton->setEnabled(false);
		ui.discardButton->setEnabled(false);
		ui.editButton->setEnabled(true);
		ui.deleteButton->setEnabled(false);
		ui.addRowButton->setEnabled(false);
		ui.deleteRowButton->setEnabled(false);
	}
	else
	{
		QString str = str.fromLocal8Bit("提示");
		QString str2 = str.fromLocal8Bit("保存失败!");
		QMessageBox::information(this,str,str2);
	}
	//ui.editButton->setEnabled(true);
	//ui.saveButton->setEnabled(false);
}
コード例 #11
0
ファイル: drugstorage.cpp プロジェクト: wangfeilong321/his
void DrugStorage::on_saveButton_clicked()
{
    static int iFlag;
    int i=0;
    int amount;
    double unitprice;
    int rows = ui.tableWidget->model()->rowCount();   //行总数
    QString str2;
    char strtemp[255]= {0};

    QString str = str.fromLocal8Bit("警告");
    unitprice = ui.lineEdit_debt->text().toDouble();
    /*if(unitprice<0)
    {
    if(ui.radioButton_Add->isChecked() && !ui.radioButton_Minus->isChecked())
    str2 = str.fromLocal8Bit("付款金额不足,请核对!");
    if(!ui.radioButton_Add->isChecked() && ui.radioButton_Minus->isChecked())
    str2 = str.fromLocal8Bit("收款金额不足,请核对!");
    QMessageBox::warning(this,str,str2,QMessageBox::Ok);
    return;
    }*/

    if(!ui.tableWidget->isEnabled())
    {
        str2 = str.fromLocal8Bit("已保存过!");
        QMessageBox::warning(this,str,str2,QMessageBox::Ok);
        return;
    }

    QSqlQuery query(*sql.db);
    QString strSheetNo=ui.lineEdit_No->text();
    QString strsql = "select * from yk_instorage where sheetno ='"+strSheetNo+"'"; //where ID > 1
    query.exec(strsql);
    int num = 0;
    QStringList list;
    int kucun2;
    while(query.next())
    {
        QString strTemp = query.value(8).toString();
        list.append(strTemp);
        num++;
    }
    int inputflag;
    for(i=0; i<num; i++)
    {
        QString strName = list[i];
        strsql = "select * from yk_instorage where sheetno ='"+strSheetNo+"'and name ='"+strName+"'"; //where ID > 1
        query.exec(strsql);
        if(query.next())
        {
            amount = query.value(13).toInt();
            inputflag = query.value(3).toInt();
        }
        strsql= "select * from yk_inventory where name ='"+strName+"'";//;//where AbbrName = '"+strName+"'
        query.exec(strsql);
        int kucun;
        if(query.next())
            kucun = query.value(7).toInt();
        if(inputflag == 1)
            kucun2 = kucun - amount;
        else
            kucun2 = kucun + amount;
        query.prepare("UPDATE yk_inventory SET count= ? WHERE name = '"+strName+"'");
        query.bindValue(0,kucun2);
        QString strTemp1 = QString::number(kucun2);
        ui.tableWidget->setItem(i,7,new QTableWidgetItem(strTemp1));
        query.exec();
    }
    if(num>0)
    {
        strsql = "delete from yk_instorage where sheetno ='"+strSheetNo+"'"; //where ID > 1
        query.exec(strsql);
        strsql = "delete from yk_instorage_public_info where sheetno ='"+strSheetNo+"'"; //where ID > 1
        query.exec(strsql);
    }

    //添加到收费单基本信息表中

    int isheetcount=PublicInfoSheetNo();
    isheetcount++;
    query.prepare("INSERT INTO yk_instorage_public_info VALUES (?, ?, ?, ?, ?, ?, ?)");
    query.bindValue(0, isheetcount);
    query.bindValue(1, ui.lineEdit_No->text());
    query.bindValue(2, ui.dateTimeEdit->dateTime());
    int iInputFlag;
    if(ui.radioButton_Add->isChecked() && !ui.radioButton_Minus->isChecked())
        iInputFlag = 1;
    else
        iInputFlag = 0;
    QString strTemp = QString::number(iInputFlag);
    query.bindValue(3, strTemp);
    strTemp = QString::number(1);
    query.bindValue(4, strTemp);
    query.bindValue(5, ui.comboBox_supplier->currentText());
    query.bindValue(6, ui.lineEdit_2->text());
    iFlag = query.exec();

    for (i=0; i< rows ; i++)
    {

        if(ui.tableWidget->item(i,6)==NULL||(ui.tableWidget->item(i,6)&& ui.tableWidget->item(i,6)->text()==tr("")))
        {
            sprintf(strtemp,"第%d行入库数量为空,请核对!",i+1);
            str2 = str.fromLocal8Bit(strtemp);
            QMessageBox::warning(this,str,str2,QMessageBox::Ok);
            return;
        }

        int isheetcount=SheetNo();
        isheetcount++;
        query.prepare("INSERT INTO yk_instorage VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
        query.bindValue(0, isheetcount);
        query.bindValue(1, ui.lineEdit_No->text());
        query.bindValue(2, ui.dateTimeEdit->dateTime());
        iInputFlag;
        if(ui.radioButton_Add->isChecked() && !ui.radioButton_Minus->isChecked())
            iInputFlag = 1;
        else
            iInputFlag = 0;
        QString strTemp = QString::number(iInputFlag);
        query.bindValue(3, strTemp);
        strTemp = QString::number(1);
        query.bindValue(4, strTemp);
        query.bindValue(5, ui.comboBox_supplier->currentText());
        query.bindValue(6, ui.lineEdit_2->text());
        if(ui.tableWidget->item(i,0)!=NULL)
        {
            query.bindValue(7, ui.tableWidget->item(i,0)->text());
        }
        else
        {
            QString strTemp = tr("");
            query.bindValue(7,strTemp );
        }

        query.bindValue(8, ui.tableWidget->item(i,1)->text());
        query.bindValue(9, ui.tableWidget->item(i,2)->text());
        query.bindValue(10, ui.tableWidget->item(i,3)->text());
        //query.bindValue(11, ui.tableWidget->item(i,4)->text());
        //query.bindValue(12, ui.tableWidget->item(i,5)->text());

        //if(ui.radioButton_Add->isChecked() && !ui.radioButton_Minus->isChecked())
        //{
        //	amount = ui.tableWidget->item(i,6)->text().toInt();
        //	unitprice = ui.tableWidget->item(i,8)->text().toDouble();
        //}else
        //{
        //	amount = -ui.tableWidget->item(i,6)->text().toInt();
        //	unitprice = -ui.tableWidget->item(i,8)->text().toDouble();
        //}
        query.bindValue(12, ui.tableWidget->item(i,5)->text());
        amount = ui.tableWidget->item(i,6)->text().toInt();
        unitprice = ui.tableWidget->item(i,8)->text().toDouble();

        query.bindValue(13, amount);
        query.bindValue(14, unitprice);
        unitprice = unitprice * amount;
        /*QString strprice= QString::number(unitprice);*/
        query.bindValue(15,unitprice);

        iFlag = query.exec();
    }

    for (i=0; i< rows ; i++)
    {
        QString strName = ui.tableWidget->item(i,1)->text();
        int kucun = ui.tableWidget->item(i,7)->text().toInt();
        int kucun1=0;
        //	kucun1 = kucun + amount;


        if(ui.radioButton_Add->isChecked() && !ui.radioButton_Minus->isChecked())
            kucun1 = kucun + amount;
        else
            kucun1 = kucun - amount;


        QString strTemp1 = QString::number(kucun1);
        ui.tableWidget->setItem(i,7,new QTableWidgetItem(strTemp1));

        QString strsql= "select * from yk_inventory where name ='"+strName+"'";//;//where AbbrName = '"+strName+"'
        query.exec(strsql);

        if(query.next())
        {
            query.prepare("UPDATE yk_inventory SET count= ? WHERE name = '"+strName+"'");
            query.bindValue(0,kucun1);
            iFlag = query.exec();
        }
        else
        {
            query.prepare("INSERT INTO yk_inventory VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
            isheetcount=InventorySheetNo();
            isheetcount ++;
            query.bindValue(0, isheetcount);
            query.bindValue(1, strName);
            query.bindValue(2, strName);
            query.bindValue(3, ui.tableWidget->item(i,2)->text());
            query.bindValue(4, ui.tableWidget->item(i,3)->text());
            query.bindValue(6, ui.tableWidget->item(i,5)->text());
            query.bindValue(7, strTemp1);
            iFlag = query.exec();

        }
    }


    if(iFlag)
    {
        QString str = str.fromLocal8Bit("提示");
        QString str2 = str.fromLocal8Bit("保存成功!");
        QMessageBox::information(this,str,str2);
        SetEdit(false);
        ui.saveButton->setEnabled(false);
        ui.discardButton->setEnabled(false);
        ui.editButton->setEnabled(true);
        ui.deleteButton->setEnabled(false);
        ui.addRowButton->setEnabled(false);
        ui.deleteRowButton->setEnabled(false);
    }
    else
    {
        QString str = str.fromLocal8Bit("提示");
        QString str2 = str.fromLocal8Bit("保存失败!");
        QMessageBox::information(this,str,str2);
    }
    //ui.editButton->setEnabled(true);
    //ui.saveButton->setEnabled(false);
}
コード例 #12
0
ファイル: drugcheck.cpp プロジェクト: wangfeilong321/his
void DrugCheck::on_saveButton_clicked()
{
	static int iFlag;
	int i=0;
	int amount;
	double unitprice;
	int rows = ui.tableWidget->model()->rowCount();   //行总数

	char strtemp[255]={0};
	//添加到收费单基本信息表中
	QSqlQuery query(*sql.db);

	
	QString str2;
	QString str = str.fromLocal8Bit("警告");
	if(!ui.tableWidget->isEnabled())
	{	
		str2 = str.fromLocal8Bit("已保存过!");		
		QMessageBox::warning(this,str,str2,QMessageBox::Ok);
		return;
	}
	
	QString strSheetNo=ui.lineEdit_CheckNo->text();
	QString strsql = "select * from yk_check where sheetno ='"+strSheetNo+"'"; //where ID > 1
	query.exec(strsql);
	if(query.next())
	{
		strsql = "delete from yk_check where sheetno ='"+strSheetNo+"'"; //where ID > 1
		query.exec(strsql);
		strsql = "delete from yk_check_public_info where sheetno ='"+strSheetNo+"'"; //where ID > 1
		query.exec(strsql);
	}

	int isheetcount=PublicInfoSheetNo();
		isheetcount++;
	query.prepare("INSERT INTO yk_check_public_info VALUES(?, ?, ?, ?, ?)");
	query.bindValue(0, isheetcount);
	query.bindValue(1, ui.lineEdit_CheckNo->text());
	query.bindValue(2, ui.dateTimeEdit->dateTime());
	query.bindValue(4, ui.lineEdit_Remark->text());
	iFlag = query.exec();


	for (i=0;i < rows ;i++)
	{
		isheetcount=SheetNo();
		isheetcount++;
		if(ui.tableWidget->item(i,7)==NULL||(ui.tableWidget->item(i,7)&& ui.tableWidget->item(i,7)->text()==tr("")))
		{
			sprintf(strtemp,"第%d行盘点数量为空,请核对!",i+1);
			str2 = str.fromLocal8Bit(strtemp);		
			QMessageBox::warning(this,str,str2,QMessageBox::Ok);
			return;
		}

		query.prepare("INSERT INTO yk_check  VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
		query.bindValue(0, isheetcount);
		query.bindValue(1, ui.lineEdit_CheckNo->text());
		query.bindValue(2, ui.dateTimeEdit->dateTime());
		query.bindValue(5, ui.tableWidget->item(i,0)->text());
		query.bindValue(6, ui.tableWidget->item(i,1)->text());
		query.bindValue(7, ui.tableWidget->item(i,2)->text());
		query.bindValue(8, ui.tableWidget->item(i,3)->text());
		query.bindValue(11, ui.tableWidget->item(i,5)->text());
		int temp;
		temp = ui.tableWidget->item(i,6)->text().toInt();
		query.bindValue(12,temp);
		temp = ui.tableWidget->item(i,7)->text().toInt();
		query.bindValue(13, temp);
		temp = ui.tableWidget->item(i,8)->text().toInt();
		query.bindValue(14, temp);
		double dtemp;
		dtemp = ui.tableWidget->item(i,9)->text().toDouble();
		query.bindValue(15, dtemp);
		dtemp = ui.tableWidget->item(i,10)->text().toDouble();
		query.bindValue(16, dtemp);
		
		iFlag = query.exec();

		QString strName = ui.tableWidget->item(i,1)->text();
		int kucun = ui.tableWidget->item(i,7)->text().toInt();


	/*	QString strTemp1 = QString::number(kucun);
		ui.tableWidget->setItem(i,7,new QTableWidgetItem(strTemp1));*/

		QString strsql= "select * from yk_inventory where name ='"+strName+"'";//;//where AbbrName = '"+strName+"'
		query.exec(strsql);

		if(query.next())
		{
			query.prepare("UPDATE yk_inventory SET count= ? WHERE name = '"+strName+"'");
			query.bindValue(0,kucun);
			iFlag = query.exec();
		}
		else
		{
			query.prepare("INSERT INTO yk_inventory VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
			isheetcount=InventorySheetNo();
			isheetcount ++;
			query.bindValue(0, isheetcount);
			query.bindValue(1, strName);
			query.bindValue(2, strName);
			query.bindValue(3, ui.tableWidget->item(i,2)->text());
			query.bindValue(4, ui.tableWidget->item(i,3)->text());
			query.bindValue(6, ui.tableWidget->item(i,5)->text());
			query.bindValue(7, kucun);
			iFlag = query.exec();
		}
	}
	if(iFlag)
	{
		QString str = str.fromLocal8Bit("提示");
		QString str2 = str.fromLocal8Bit("保存成功!");
//		QMessageBox::information(this,str,str2);
//		ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
		SetEdit(false);
		ui.saveButton->setEnabled(false);
		ui.discardButton->setEnabled(false);
		ui.editButton->setEnabled(true);
		ui.deleteButton->setEnabled(true);
		ui.addRowButton->setEnabled(false);
		ui.deleteRowButton->setEnabled(false);
	}
	else
	{
		QString str = str.fromLocal8Bit("提示");
		QString str2 = str.fromLocal8Bit("保存失败!");
		QMessageBox::information(this,str,str2);
	}
}