我在C#项目的实体框架中遇到了两个问题 [英] I am facing 2 issues in entity framework in my C# project

查看:92
本文介绍了我在C#项目的实体框架中遇到了两个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys我面临2个问题。一个是它显示我错误的物品总价格,第二个是我想添加价格.00

你可以清楚地查看这张照片中的问题解释

我正在使用编码:

Hello Guys i am facing 2 issue.one is it's shows me wrong total of items price and second is it's i want to add with price .00
you can check issue in this picture with clearly explanation
am using coding for this:

txtDisplay.Text = "Return/" + "Receipt No:" + Return_Form.setalueforText011;
            label1.Text = Return_Form.setalueforText011;
            OleDbConnection VCON = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Restaurant.accdb");
            DataSet dsa = new DataSet();
            DataTable dt = new DataTable();
            dsa.Tables.Add(dt);
            OleDbDataAdapter da = new OleDbDataAdapter();
            da = new OleDbDataAdapter("SELECT [Column1],[Column2],[Column3] from [Total] Where [Receipt No] =  " + label1.Text + "", VCON);
            da.Fill(dt);
            //dataGridView1.DataSource = dt;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                products.Add(new tblProduct() { productName = dt.Rows[i]["Column2"].ToString(),productPrice = Convert.ToDecimal(Math.Round(Convert.ToDecimal(dt.Rows[i]["Column1"].ToString())))});
                label3.Text = dt.Rows[i]["Column3"].ToString();
                textBox59.Text = "Rs: "+String.Format("{0:}", Total);
                tblProduct selected = (tblProduct)(listBox60.SelectedItem);
                Total += (decimal)selected.productPrice;
            }
                VCON.Close();





我尝试过:



i我多次尝试这段代码,但它再次显示了我的同样重要性,请告诉我这段代码有什么问题



What I have tried:

i am trying this code many times but it's shows me same reuslt again and agian please help me what's wrong with this code

推荐答案

不知道你的意思是错误的物品总价格。但是,请参阅标准数字格式字符串 [ ^ ]了解如何格式化你想要的数字。



同样根据你的控制名来判断(例如 textBox59 listBox60 )在代码中生成错误非常容易;你应该将所有这些改为有意义的名字,这样你就可以快速查看你正在使用的控件。
No idea what you mean by "wrong total of items price". However, see Standard Numeric Format Strings[^] to see how to format the numbers the way you want.

Also judging by your control names (e.g textBox59 and listBox60) it is quite easy to generate errors in your code; you should change all of those to meaningful names so you can quickly see what control you are using.


这篇关于我在C#项目的实体框架中遇到了两个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆