我想计算总工资总额,任何人都可以告诉我 [英] i want to calculate total gross salary hoew can i do that any one tell me

查看:179
本文介绍了我想计算总工资总额,任何人都可以告诉我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算总薪水水平,任何人都可以告诉我
我有1>基本萨尔
2> HRD
3> DA
4> P.F
5> Gross Sal
6>净付费
当我自动在文本框中输入基本薪水时,我想在datagridview中进行总计计算
我该怎么做,任何人都告诉我



这是我的代码


i want to calculate total gross salary hoew can i do that any one tell me
i have 1>Basic Sal
2>HRD
3>DA
4>P.F
5>Gross Sal
6>Net Paid
when i enter basic salary in textbox automatically i want to come total calculate in datagridview
how can i do that any one tell me



this is my code


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace treeview_grossalary
{
    public partial class Form1 : Form
    {
        SqlConnection con = new SqlConnection("Data Source=CIODEV03\\SQLEXPRESS;Initial Catalog=EmployeeDB;Integrated Security=True");
        SqlCommand cmd = new SqlCommand();

        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            getdata();


        }
        private void getdata()
        {
            string str = "select * from gridsalry";
            SqlDataAdapter ada = new SqlDataAdapter(str, con);
            DataSet ds = new DataSet();
            ada.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];
             }

        private void btnsave_Click_1(object sender, EventArgs e)
        {
            string str = "insert into gridsalry values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "')";
            con.Open();
            cmd = new SqlCommand(str, con);
            cmd.ExecuteNonQuery();
            con.Close();
            getdata();
           }
        
    }

}

推荐答案

在textbox_keypress事件检查中,
In the textbox_keypress event check,
e.Keychar == (char)13


13是ASCII码的回车键

因此,请在此例程中计算您的总金额.

希望这会给你一个主意.

如有任何问题,请再次询问.


13 is ASCII for enter key

So in this routine calculate your total gross amount.

Hope this will give u an idea.

If any problem please ask again.


请勿使用字符串串联来创建SQL命令,这会使您的应用程序容易受到SQL注入攻击的影响,并可能破坏整个数据库.计算总薪水很简单,只需编写代码即可根据薪资和税法规则进行相关计算.由于我们不知道这些规则是什么,因此我们无法为您提供答案.
Do not use string concatenation to create SQL commands, this leaves your application wide open to SQL injection attacks and could destroy your entire database. Calculating gross salary is a simple matter of writing the code to do the relevant calculations according to your payroll and tax rules. Since we do not know what those rules are we cannot give you the answer.


总工资中的TextChanged事件

我们可以获取值
基本工资
HRD
DA
P.F
工资总额
净付费

我们可以添加所有这些值...

TextBox8.Text + = ....
In gross salary TextChanged event

we can get values
Basic Sal
HRD
DA
P.F
Gross Sal
Net Paid

in that we can add all those values...

TextBox8.Text+=....


这篇关于我想计算总工资总额,任何人都可以告诉我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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