private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            ConnDB conn = new ConnDB();
            string strsql, strsql2;
            int    rows;

            strsql  = "insert into cost_direct_labour(CNO,CNAME,DEPT_ID,POSITION_ID,LINETYPE_ID,PERSON_TYPE_ID,FORBIDDEN) values(LTRIM(rtrim('" + textEditNo.Text.ToString() + "')),LTRIM(rtrim('" + textEditName.Text.ToString() + "'))," + comboBoxDept.SelectedValue.ToString() + "," + comboBoxPosition.SelectedValue.ToString() + "," + Common.IsZero(comboBoxLineType.SelectedValue.ToString()) + ",3,0)";
            strsql2 = "select cname from cost_direct_labour where cno = LTRIM(rtrim('" + textEditNo.Text.ToString().Trim() + "'))";
            if (textEditNo.Text.ToString().Trim() != "")
            {
                rows = conn.ReturnRecordCount(strsql2);
                if (rows > 0)
                {
                    MessageBox.Show("该人员已经存在!");
                }
                else
                {
                    bool isok = conn.EditDatabase(strsql);
                    if (isok)
                    {
                        MessageBox.Show("添加成功!");
                        DirectLabourQuery.RefreshEX();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("失败!");
                    }
                }
            }
            else
            {
                MessageBox.Show("工号不能为空!");
            }
            conn.Close();
        }
        private void showDetail()
        {
            ConnDB conn = new ConnDB();
            string strsql;
            int    linetypeid, deptid;

            deptid     = (int)comboBoxDept.SelectedValue;
            linetypeid = (int)comboBoxLineType.SelectedValue;
            if (deptid > 0)
            {
                if (linetypeid > 0)
                {
                    strsql = "select i.cno 工号,i.cname 姓名,d.cname 部门,j.cname 职位,e.cname 拉别,i.cid,j.cid,e.cid,d.cid,i.forbidden 禁用 from cost_direct_labour i left join cost_position j on i.position_id = j.cid left join cost_linetype e on i.linetype_id = e.cid left join cost_dept d on i.dept_id = d.cid where i.linetype_id = " + Common.IsZero(linetypeid.ToString()) + " and i.dept_id = " + Common.IsZero(deptid.ToString()) + " and i.person_type_id = 3 order by i.cname";
                }
                else
                {
                    strsql = "select i.cno 工号,i.cname 姓名,d.cname 部门,j.cname 职位,e.cname 拉别,i.cid,j.cid,e.cid,d.cid,i.forbidden 禁用 from cost_direct_labour i left join cost_position j on i.position_id = j.cid left join cost_linetype e on i.linetype_id = e.cid left join cost_dept d on i.dept_id = d.cid where i.dept_id = " + Common.IsZero(deptid.ToString()) + " and i.person_type_id = 3 order by i.cname";
                }
            }
            else
            {
                if (linetypeid > 0)
                {
                    strsql = "select i.cno 工号,i.cname 姓名,d.cname 部门,j.cname 职位,e.cname 拉别,i.cid,j.cid,e.cid,d.cid,i.forbidden 禁用 from cost_direct_labour i left join cost_position j on i.position_id = j.cid left join cost_linetype e on i.linetype_id = e.cid left join cost_dept d on i.dept_id = d.cid where i.linetype_id = " + Common.IsZero(linetypeid.ToString()) + " and i.person_type_id = 3 order by i.cname";
                }
                else
                {
                    strsql = "select i.cno 工号,i.cname 姓名,d.cname 部门,j.cname 职位,e.cname 拉别,i.cid,j.cid,e.cid,d.cid,i.forbidden 禁用 from cost_direct_labour i left join cost_position j on i.position_id = j.cid left join cost_linetype e on i.linetype_id = e.cid left join cost_dept d on i.dept_id = d.cid where i.person_type_id = 3 order by i.cname";
                }
            }
            DataSet ds = conn.ReturnDataSet(strsql);

            gridControl1.DataSource      = ds.Tables[0].DefaultView;
            gridView1.Columns[5].Visible = false;
            gridView1.Columns[6].Visible = false;
            gridView1.Columns[7].Visible = false;
            gridView1.Columns[8].Visible = false;
            gridView1.Columns[0].OptionsColumn.ReadOnly = true;
            gridView1.Columns[1].OptionsColumn.ReadOnly = true;
            gridView1.Columns[2].OptionsColumn.ReadOnly = true;
            gridView1.Columns[3].OptionsColumn.ReadOnly = true;
            gridView1.Columns[4].OptionsColumn.ReadOnly = true;
            gridView1.Columns[5].OptionsColumn.ReadOnly = true;
            gridView1.Columns[6].OptionsColumn.ReadOnly = true;
            gridView1.Columns[7].OptionsColumn.ReadOnly = true;
            gridView1.Columns[8].OptionsColumn.ReadOnly = true;
            gridView1.Columns[9].OptionsColumn.ReadOnly = true;
            IsForbidden();
            conn.Close();
        }
Example #3
0
        private void showDetail()
        {
            ConnDB conn = new ConnDB();
            string strsql;
            int    persontypeid;

            persontypeid = (int)comboBoxPersonType.SelectedValue;
            if (persontypeid > 0)
            {
                strsql = "select i.cname 职位,j.cname 人力类型,i.cid,j.cid,i.forbidden 禁用 from cost_position i left join cost_person_type j on i.person_type_id = j.cid where i.person_type_id = " + Common.IsZero(persontypeid.ToString()) + " order by i.cname";
            }
            else
            {
                strsql = "select i.cname 职位,j.cname 人力类型,i.cid,j.cid,i.forbidden 禁用 from cost_position i left join cost_person_type j on i.person_type_id = j.cid order by i.cname";
            }

            DataSet ds = conn.ReturnDataSet(strsql);

            gridControl1.DataSource      = ds.Tables[0].DefaultView;
            gridView1.Columns[2].Visible = false;
            gridView1.Columns[3].Visible = false;
            gridView1.Columns[0].OptionsColumn.ReadOnly = true;
            gridView1.Columns[1].OptionsColumn.ReadOnly = true;
            gridView1.Columns[2].OptionsColumn.ReadOnly = true;
            gridView1.Columns[3].OptionsColumn.ReadOnly = true;
            gridView1.Columns[4].OptionsColumn.ReadOnly = true;

            IsForbidden();
            conn.Close();
        }
Example #4
0
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            ConnDB conn = new ConnDB();
            string strsql, strsql2;
            int    rows;

            strsql  = "insert into cost_rate(yyyy,quarter_id,sale_type_id,cost_rate) values('" + dateTimePicker1.Text.ToString() + "'," + comboBoxQuarter.SelectedValue.ToString() + "," + comboBoxSaleType.SelectedValue.ToString() + ",ltrim(rtrim(" + Common.IsNull(textEditCostRate.Text.ToString()) + ")))";
            strsql2 = "select * from cost_rate where yyyy ='" + dateTimePicker1.Text.ToString() + "' and sale_type_id = " + Common.IsZero(comboBoxSaleType.SelectedValue.ToString()) + " and quarter_id = " + Common.IsZero(comboBoxQuarter.SelectedValue.ToString());
            if (comboBoxQuarter.SelectedValue.ToString() == "0")
            {
                MessageBox.Show("请选择季度");
            }
            else if (comboBoxSaleType.SelectedValue.ToString() == "0")
            {
                MessageBox.Show("请选择营业类型");
            }
            else if (textEditCostRate.Text.ToString() == "")
            {
                MessageBox.Show("成本比率不能为空!");
            }
            else
            {
                rows = conn.ReturnRecordCount(strsql2);
                if (rows > 0)
                {
                    MessageBox.Show("该成本比率已经存在!");
                }
                else
                {
                    bool isok = conn.EditDatabase(strsql);
                    if (isok)
                    {
                        MessageBox.Show("添加成功!");
                        CostRateQuery.RefreshEX();
                        this.Close();
                    }
                }
            }
            conn.Close();
        }
Example #5
0
 private void simpleButton复制_Click(object sender, EventArgs e)
 {
     if (comboBoxQuarter.SelectedValue.ToString() == "0")
     {
         MessageBox.Show("请选择季度");
     }
     else
     {
         MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
         DialogResult      dr         = MessageBox.Show("将按最近的季度数据自动新增当前选择季度的数据,确认复制吗?", "复制最近季度数据", messButton);
         if (dr == DialogResult.OK)
         {
             ConnDB conn = new ConnDB();
             string strsql, strsql2;
             int    rows;
             bool   isok = false;
             strsql2 = "select * from cost_rate where yyyy ='" + dateTimePicker1.Text.ToString() + "' and quarter_id = " + Common.IsZero(comboBoxQuarter.SelectedValue.ToString());
             rows    = conn.ReturnRecordCount(strsql2);
             if (rows > 0)
             {
                 MessageBox.Show("该季度成本比率已经存在!");
             }
             else
             {
                 strsql = "insert into cost_rate(yyyy,quarter_id,sale_type_id,cost_rate) select '" + dateTimePicker1.Text + "','" + Common.IsZero(comboBoxQuarter.SelectedValue.ToString()) + "',sale_type_id,cost_rate from cost_rate where YYYY + cast(quarter_id as varchar(10)) = (select Max(yyyy+cast(quarter_id as varchar(10))) from cost_rate where isnull(dept_id,0) = 0) ";
                 isok   = conn.EditDatabase(strsql);
                 if (isok)
                 {
                     MessageBox.Show("复制成功!");
                     CostRateQuery.RefreshEX();
                     this.Close();
                 }
             }
             conn.Close();
         }
     }
 }
        private void simpleButtonSubmit_Click(object sender, EventArgs e)
        {
            if (comboBoxWorkType.SelectedValue.ToString() == "0")
            {
                MessageBox.Show("上班类型没有设置!");
            }
            else if (ischange == true)
            {
                ConnDB conn = new ConnDB();
                string strsql, strsql2;
                int    deptid, worktypeid;

                bool isok = false;
                deptid     = (int)comboBoxDept.SelectedValue;
                worktypeid = (int)comboBoxWorkType.SelectedValue;
                if (deptid > 0)
                {
                    strsql = "select i.* from COST_DIRECT_LABOUR_ATTENDANCE i left join COST_DIRECT_LABOUR j on i.DIRECT_LABOUR_ID = j.CID left join COST_DEPT D on j.DEPT_ID = D.CID where j.person_type_id = 4 and j.DEPT_ID = " + Common.IsZero(deptid.ToString()) + " and cdate = '" + dateEditDate.Text + "'";
                }
                else
                {
                    strsql = "select i.* from COST_DIRECT_LABOUR_ATTENDANCE i left join COST_DIRECT_LABOUR j on i.DIRECT_LABOUR_ID = j.CID left join COST_DEPT D on j.DEPT_ID = D.CID where j.person_type_id = 4 and cdate = '" + dateEditDate.Text + "'";
                }
                DataSet ds = conn.ReturnDataSet(strsql);

                gridView1.FocusInvalidRow();
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    bool    exist = false;
                    decimal h;
                    if (gridView1.GetDataRow(i).ItemArray[9].ToString() == "")
                    {
                        h = 0;
                    }
                    else
                    {
                        h = Convert.ToDecimal(gridView1.GetDataRow(i).ItemArray[9]);
                    }
                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                    {
                        if (gridView1.GetDataRow(i).ItemArray[0].ToString() == ds.Tables[0].Rows[j][0].ToString())
                        {
                            strsql2 = "update i set i.work_type_id = " + worktypeid + ",i.hours = " + h + " from COST_DIRECT_LABOUR_ATTENDANCE i where i.cid = " + gridView1.GetDataRow(i).ItemArray[0].ToString();
                            isok    = conn.EditDatabase(strsql2);
                            exist   = true;
                            break;
                        }
                    }
                    if (!exist)
                    {
                        strsql2 = "insert into COST_DIRECT_LABOUR_ATTENDANCE(cdate,direct_labour_id,work_type_id,hours) values('" + gridView1.GetDataRow(i).ItemArray[1].ToString() + "'," + gridView1.GetDataRow(i).ItemArray[4].ToString() + "," + worktypeid + "," + h + ")";
                        isok    = conn.EditDatabase(strsql2);
                    }
                }

                if (isok)
                {
                    MessageBox.Show("提交成功!");
                    comboBoxWorkType.SelectedIndex = -1;
                    comboBoxWorkType.SelectedValue = 0;
                    textEditHours.Text             = "0";
                    showDetail();
                }
                else
                {
                    MessageBox.Show("失败!");
                }
                //dlpuform.ischange = false;
                conn.Close();
                ischange = false;
            }
            else
            {
                MessageBox.Show("没有可更新的数据!");
            }
        }
        private void showDetail2()
        {
            ConnDB conn = new ConnDB();
            string strsql;
            int    deptid;

            deptid = (int)comboBoxDept.SelectedValue;
            if (deptid > 0)
            {
                strsql = "select isnull(i.cid,0) id,'" + dateEditDate.Text + "' 日期,d.cid 部门id,d.cname 部门,j.cid 直接人工id,j.cno 工号,j.cname 姓名,i.work_type_id 上班类型id,w.cname 上班类型,'" + Common.IsNull(textEditHours.Text.ToString()) + "' 小时数 from (select * from COST_DIRECT_LABOUR_ATTENDANCE where cdate = '" + dateEditDate.Text + "') i right join COST_DIRECT_LABOUR j on i.DIRECT_LABOUR_ID = j.CID left join COST_DEPT D on j.DEPT_ID = D.CID left join cost_work_type w on i.work_type_id = w.cid where j.person_type_id = 4 and D.cid = " + Common.IsZero(deptid.ToString()) + " order by d.cname";
            }
            else
            {
                strsql = "select isnull(i.cid,0) id,'" + dateEditDate.Text + "' 日期,d.cid 部门id,d.cname 部门,j.cid 直接人工id,j.cno 工号,j.cname 姓名,i.work_type_id 上班类型id,w.cname 上班类型,'" + Common.IsNull(textEditHours.Text.ToString()) + "' 小时数 from(select * from COST_DIRECT_LABOUR_ATTENDANCE where cdate = '" + dateEditDate.Text + "') i right join COST_DIRECT_LABOUR j on i.DIRECT_LABOUR_ID = j.CID left join COST_DEPT D on j.DEPT_ID = D.CID left join cost_work_type w on i.work_type_id = w.cid where j.person_type_id = 4 order by d.cname";
            }

            DataSet ds = conn.ReturnDataSet(strsql);

            gridControl1.DataSource      = ds.Tables[0].DefaultView;
            gridView1.Columns[0].Visible = false;
            gridView1.Columns[2].Visible = false;
            gridView1.Columns[4].Visible = false;
            gridView1.Columns[7].Visible = false;

            gridView1.Columns[0].OptionsColumn.ReadOnly = true;
            gridView1.Columns[1].OptionsColumn.ReadOnly = true;
            gridView1.Columns[2].OptionsColumn.ReadOnly = true;
            gridView1.Columns[3].OptionsColumn.ReadOnly = true;
            gridView1.Columns[4].OptionsColumn.ReadOnly = true;
            gridView1.Columns[5].OptionsColumn.ReadOnly = true;
            gridView1.Columns[6].OptionsColumn.ReadOnly = true;
            gridView1.Columns[7].OptionsColumn.ReadOnly = true;
            gridView1.Columns[8].OptionsColumn.ReadOnly = true;
            conn.Close();
        }
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            ConnDB conn = new ConnDB();
            string strsql, strsql2;
            int    rows;

            strsql  = "insert into cost_transfer(cdate,sale_type_id,transfer_type,hours) values('" + dateEditDate.Text.ToString() + "','" + Common.IsZero(comboBoxSaleType.SelectedValue.ToString()) + "','" + Common.IsZero(comboBoxTransferType.SelectedValue.ToString()) + "'," + textEditHours.Text.ToString().Trim() + ")";
            strsql2 = "select cdate from cost_transfer where cdate ='" + dateEditDate.Text.ToString() + "' and sale_type_id = " + comboBoxSaleType.SelectedValue.ToString() + " and transfer_type = " + comboBoxTransferType.SelectedValue.ToString();
            if (textEditHours.Text.ToString() != "")
            {
                rows = conn.ReturnRecordCount(strsql2);
                if (rows > 0)
                {
                    MessageBox.Show("此转嫁工时已经存在!");
                }
                else
                {
                    bool isok = conn.EditDatabase(strsql);
                    if (isok)
                    {
                        MessageBox.Show("添加成功!");
                        CostTransferQuery.RefreshEX();
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show("转嫁工时不能为空!");
            }
            conn.Close();
        }
Example #9
0
        public void BindDept()
        {
            ConnDB  conn = new ConnDB();
            string  sql  = "select * from  cost_dept where isnull(forbidden,'false') != 'true' and saletype_id = " + Common.IsZero(comboBoxSaleType.SelectedValue.ToString());
            DataSet ds   = conn.ReturnDataSet(sql);
            DataRow dr   = ds.Tables[0].NewRow();

            dr[0] = "0";
            dr[1] = "请选择";
            //插在第一位
            ds.Tables[0].Rows.InsertAt(dr, 0);
            comboBoxDept.DataSource    = ds.Tables[0];
            comboBoxDept.DisplayMember = "CNAME";
            comboBoxDept.ValueMember   = "CID";
            conn.Close();
        }
Example #10
0
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            ConnDB conn = new ConnDB();
            string sql  = "update cost_direct_labour set cno = ltrim(rtrim('" + textEditNo.Text.ToString().Trim() + "')),cname = ltrim(rtrim('" + textEditName.Text.ToString().Trim() + "')),position_id = " + Common.IsZero(comboBoxPosition.SelectedValue.ToString()) + ",linetype_id =" + Common.IsZero(comboBoxLineType.SelectedValue.ToString()) + ",dept_id =" + comboBoxDept.SelectedValue.ToString();

            sql = sql + " where cid = " + textEditID.Text.ToString();
            string sql2 = "select cname from cost_direct_labour where cno = '" + textEditNo.Text.ToString().Trim() + "' and cid <> " + textEditID.Text;
            string sql3 = "select * from cost_direct_labour where cno = '" + textEditNo.Text.ToString().Trim() + "' and cname ='" + textEditName.Text.ToString().Trim() + "' and position_id = " + comboBoxPosition.SelectedValue.ToString() + " and linetype_id =" + comboBoxLineType.SelectedValue.ToString() + " and dept_id =" + comboBoxDept.SelectedValue.ToString();

            if (textEditNo.Text.ToString().Trim() != "" && textEditName.Text.ToString().Trim() != "" && comboBoxPosition.SelectedValue.ToString() != "0" && comboBoxDept.SelectedValue.ToString() != "0")
            {
                int rows  = conn.ReturnRecordCount(sql2);
                int rows2 = conn.ReturnRecordCount(sql3);
                if (rows > 0)
                {
                    MessageBox.Show("该工号已经存在!");
                }
                else if (rows2 > 0)
                {
                    MessageBox.Show("该人员已经存在!");
                }
                else
                {
                    bool isok = conn.EditDatabase(sql);
                    if (isok)
                    {
                        MessageBox.Show("修改成功!");
                        DirectLabourQuery.RefreshEX();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("失败!");
                    }
                }
            }
            else
            {
                MessageBox.Show("不能为空值!");
            }
            conn.Close();
        }
Example #11
0
        private void showDetail()
        {
            ConnDB conn = new ConnDB();
            string strsql;
            int    saletypeid;

            saletypeid = (int)comboBoxSaleType.SelectedValue;
            if (saletypeid > 0)
            {
                strsql = "select j.cname 营业类型,d.cname 车间,i.cname ERP中线体,i.cname_mes MES中线体,d.sub_id,i.cid,j.cid,i.forbidden 禁用 from cost_linetype i left join cost_saletype j on i.saletype_id = j.cid left join cost_base_data d on d.module_id = 3 and i.work_shop = d.sub_id where i.saletype_id = " + Common.IsZero(saletypeid.ToString()) + " order by i.cname";
            }
            else
            {
                strsql = "select j.cname 营业类型,d.cname 车间,i.cname ERP中线体,i.cname_mes MES中线体,d.sub_id,i.cid,j.cid,i.forbidden 禁用 from cost_linetype i left join cost_saletype j on i.saletype_id = j.cid left join cost_base_data d on d.module_id = 3 and i.work_shop = d.sub_id order by i.cname";
            }

            DataSet ds = conn.ReturnDataSet(strsql);

            gridControl1.DataSource      = ds.Tables[0].DefaultView;
            gridView1.Columns[4].Visible = false;
            gridView1.Columns[5].Visible = false;
            gridView1.Columns[6].Visible = false;
            gridView1.Columns[0].OptionsColumn.ReadOnly = true;
            gridView1.Columns[1].OptionsColumn.ReadOnly = true;
            gridView1.Columns[2].OptionsColumn.ReadOnly = true;
            gridView1.Columns[3].OptionsColumn.ReadOnly = true;
            gridView1.Columns[4].OptionsColumn.ReadOnly = true;
            gridView1.Columns[5].OptionsColumn.ReadOnly = true;
            gridView1.Columns[6].OptionsColumn.ReadOnly = true;
            gridView1.Columns[7].OptionsColumn.ReadOnly = true;

            IsForbidden();
            conn.Close();
        }
        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            ConnDB conn = new ConnDB();
            string strsql, strsql2;
            int    rows;

            strsql  = "insert into cost_dept_standard_point(yyyymm,sale_type_id,dept_id,dept_standard_point) values('" + dateTimePicker1.Text.ToString() + "'," + comboBoxSaleType.SelectedValue.ToString() + "," + comboBoxDept.SelectedValue.ToString() + ",ltrim(rtrim(" + textEditDeptStandardPoint.Text.ToString() + ")))";
            strsql2 = "select * from cost_dept_standard_point where yyyymm ='" + dateTimePicker1.Text.ToString() + "' and sale_type_id = " + Common.IsZero(comboBoxSaleType.SelectedValue.ToString()) + " and dept_id = " + Common.IsZero(comboBoxDept.SelectedValue.ToString());
            if (comboBoxSaleType.SelectedValue.ToString() == "0")
            {
                MessageBox.Show("请选择营业分类!");
            }
            else if (comboBoxDept.SelectedValue.ToString() == "0")
            {
                MessageBox.Show("请选择部门!");
            }
            else if (textEditDeptStandardPoint.Text.ToString() == "")
            {
                MessageBox.Show("部门标准单点成本不能为空!");
            }
            else
            {
                rows = conn.ReturnRecordCount(strsql2);
                if (rows > 0)
                {
                    MessageBox.Show("该单点标准成本已经存在!");
                }
                else
                {
                    bool isok = conn.EditDatabase(strsql);
                    if (isok)
                    {
                        MessageBox.Show("添加成功!");
                        DeptStandardPointQuery.RefreshEX();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("失败!");
                    }
                }
            }
            conn.Close();
        }