Ejemplo n.º 1
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void toolStripMenuItem_DataGridViewRowDelete_Click(object sender, EventArgs e)
 {
     if (Class_KindofEmployerWelder.ExistAndCanDeleteAndDelete((int)this.dataGridView_Data.CurrentRow.Cells["KindofEmployerWelderID"].Value, Enum_zwjKindofUpdate.CanDelete))
     {
         if (MessageBox.Show("确认删除吗?", "确认窗口", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             Class_KindofEmployerWelder.ExistAndCanDeleteAndDelete((int)this.dataGridView_Data.CurrentRow.Cells["KindofEmployerWelderID"].Value, Enum_zwjKindofUpdate.Delete);
             this.RefreshData(false);
         }
     }
     else
     {
         MessageBox.Show("不能删除!");
     }
 }
 private void Form_KindofEmployerWelder_Update_Load(object sender, EventArgs e)
 {
     if (!(this.bool_Add || Class_KindofEmployerWelder.ExistAndCanDeleteAndDelete(myClass_KindofEmployerWelder.KindofEmployerWelderID, Enum_zwjKindofUpdate.Exist)))
     {
         MessageBox.Show("不存在该项,可能已删除!");
         this.DialogResult = DialogResult.Cancel;
         this.Close();
         return;
     }
     this.label_ErrMessage.Text = "";
     if (!Class_zwjPublic.myBackColor.IsEmpty)
     {
         this.BackColor = Class_zwjPublic.myBackColor;
     }
     this.userControl_KindofEmployerWelder_Base1.InitControl(this.myClass_KindofEmployerWelder, this.bool_Add);
 }
Ejemplo n.º 3
0
        private void toolStripMenuItem_RowSynchronizationhdhr_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认同步用友数据吗?", "确认窗口", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            string         str_SQL           = "SELECT docname FROM [hdhr].[dbo].[v_defdoc_xueli]";
            SqlDataAdapter myAdapter         = new SqlDataAdapter(str_SQL, Properties.Settings.Default.zwjConnhdhr);
            DataTable      myDataTable_xueli = new DataTable();

            myAdapter.Fill(myDataTable_xueli);
            Class_Schooling myClass_Schooling = new Class_Schooling();

            foreach (DataRow myDataRow in myDataTable_xueli.Rows)
            {
                if (!Class_Schooling.ExistAndCanDeleteAndDelete(myDataRow["docname"].ToString(), Enum_zwjKindofUpdate.Exist))
                {
                    myClass_Schooling.Schooling = myDataRow["docname"].ToString();
                    myClass_Schooling.AddAndModify(Enum_zwjKindofUpdate.Add);
                }
            }

            str_SQL = "SELECT [ryid],[ryxm],[ryxb],[xlmc],[rygh],[jcrq],[gsmc],[bmmc],[kscj],[lwgs] FROM [hdhr].[dbo].[v_psninfo_to_hangong]";
            Class_KindofEmployer myClass_KindofEmployer = new Class_KindofEmployer(this.myEventArgs_KindofEmployer.str_KindofEmployer);
            Class_Employer       myClass_Employer       = new Class_Employer(myClass_KindofEmployer.KindofEmployerEmployerHPID);
            Class_Department     myClass_Department     = new Class_Department(myClass_KindofEmployer.KindofEmployerDepartmentHPID);
            Class_WorkPlace      myClass_WorkPlace      = new Class_WorkPlace(myClass_KindofEmployer.KindofEmployerWorkPlaceHPID);

            switch (myClass_KindofEmployer.KindofEmployerLevel)
            {
            case 1:
                str_SQL += string.Format(" where gsmc='{0}'", myClass_Employer.Employer);
                break;

            case 2:
                str_SQL += string.Format(" where gsmc='{0}' and bmmc='{1}'", myClass_Employer.Employer, myClass_Department.Department);
                break;

            case 3:
                str_SQL += string.Format(" where gsmc='{0}' and bmmc='{1}' and kscj='{2}'", myClass_Employer.Employer, myClass_Department.Department, myClass_WorkPlace.WorkPlace);
                break;

            default:
                return;
            }
            myAdapter = new SqlDataAdapter(str_SQL, Properties.Settings.Default.zwjConnhdhr);
            DataTable myDataTable_hdhrhangong = new DataTable();

            myAdapter.Fill(myDataTable_hdhrhangong);
            Class_KindofEmployerWelder myClass_KindofEmployerWelder = new Class_KindofEmployerWelder();

            myClass_KindofEmployerWelder.KindofEmployer = myClass_KindofEmployer.KindofEmployer;
            string        str_Err;
            int           i_success           = 0;
            int           i_success_add       = 0;
            int           i_success_modify    = 0;
            int           i_success_delete    = 0;
            int           i_fail              = 0;
            StringBuilder myStringBuilder_err = new StringBuilder();

            foreach (DataRow myDataRow in this.myDataTable.Rows)
            {
                if (myDataTable_hdhrhangong.Select(string.Format("ryid='{0}'", myDataRow["IdentificationCard"])).GetLength(0) == 0)
                {
                    Class_KindofEmployerWelder.ExistAndCanDeleteAndDelete((int)myDataRow["KindofEmployerWelderID"], Enum_zwjKindofUpdate.Delete);
                    i_success_delete++;
                }
            }

            foreach (DataRow myDataRow in myDataTable_hdhrhangong.Rows)
            {
                myClass_KindofEmployerWelder.IdentificationCard = myDataRow["ryid"].ToString();
                myClass_KindofEmployerWelder.WelderName         = myDataRow["ryxm"].ToString();
                myClass_KindofEmployerWelder.Sex       = myDataRow["ryxb"].ToString();
                myClass_KindofEmployerWelder.Schooling = myDataRow["xlmc"].ToString();
                if (!DateTime.TryParse(myDataRow["jcrq"].ToString(), out myClass_KindofEmployerWelder.WeldingBeginning))
                {
                    myClass_KindofEmployerWelder.WeldingBeginning = DateTime.Now;
                }
                myClass_KindofEmployerWelder.myClass_BelongUnit.WorkerID     = myDataRow["rygh"].ToString();
                myClass_KindofEmployerWelder.myClass_BelongUnit.EmployerHPID = Class_Employer.GetEmployerHPID(myDataRow["gsmc"].ToString());
                if (string.IsNullOrEmpty(myClass_KindofEmployerWelder.myClass_BelongUnit.EmployerHPID))
                {
                    i_fail++;
                    myStringBuilder_err.Append(string.Format("\n身份证号码:{0}, 错误信息:公司名称不符", myClass_KindofEmployerWelder.IdentificationCard));
                    continue;
                }
                else
                {
                    myClass_KindofEmployerWelder.myClass_BelongUnit.DepartmentHPID = Class_Department.GetDepartmentHPID(myClass_KindofEmployerWelder.myClass_BelongUnit.EmployerHPID, myDataRow["bmmc"].ToString());
                    if (string.IsNullOrEmpty(myClass_KindofEmployerWelder.myClass_BelongUnit.DepartmentHPID))
                    {
                        myClass_KindofEmployerWelder.myClass_BelongUnit.WorkPlaceHPID = null;
                    }
                    else
                    {
                        myClass_KindofEmployerWelder.myClass_BelongUnit.WorkPlaceHPID = Class_WorkPlace.GetWorkPlaceHPID(myClass_KindofEmployerWelder.myClass_BelongUnit.DepartmentHPID, myDataRow["kscj"].ToString());
                    }
                    myClass_KindofEmployerWelder.myClass_BelongUnit.LaborServiceTeamHPID = Class_LaborServiceTeam.GetLaborServiceTeamHPID(myClass_KindofEmployerWelder.myClass_BelongUnit.EmployerHPID, myDataRow["lwgs"].ToString());
                }
                str_Err = myClass_KindofEmployerWelder.CheckField();
                if (string.IsNullOrEmpty(str_Err))
                {
                    if (Class_KindofEmployerWelder.ExistSecond(myClass_KindofEmployerWelder.KindofEmployer, myClass_KindofEmployerWelder.IdentificationCard, 0, Enum_zwjKindofUpdate.Add))
                    {
                        myClass_KindofEmployerWelder.KindofEmployerWelderID = Class_KindofEmployerWelder.GetKindofEmployerWelderID(myClass_KindofEmployerWelder.KindofEmployer, myClass_KindofEmployerWelder.IdentificationCard);
                        myClass_KindofEmployerWelder.AddAndModify(Enum_zwjKindofUpdate.Modify);
                        i_success_modify++;
                        i_success++;
                    }
                    else
                    {
                        myClass_KindofEmployerWelder.AddAndModify(Enum_zwjKindofUpdate.Add);
                        i_success_add++;
                        i_success++;
                        if (!Class_Welder.ExistAndCanDeleteAndDelete(myClass_KindofEmployerWelder.IdentificationCard, Enum_zwjKindofUpdate.Exist))
                        {
                            Class_Welder myClass_Welder = new Class_Welder();
                            myClass_Welder.IdentificationCard = myClass_KindofEmployerWelder.IdentificationCard;
                            myClass_Welder.Schooling          = myClass_KindofEmployerWelder.Schooling;
                            myClass_Welder.Sex                = myClass_KindofEmployerWelder.Sex;
                            myClass_Welder.WelderName         = myClass_KindofEmployerWelder.WelderName;
                            myClass_Welder.WeldingBeginning   = myClass_KindofEmployerWelder.WeldingBeginning;
                            myClass_Welder.myClass_BelongUnit = myClass_KindofEmployerWelder.myClass_BelongUnit;
                            myClass_Welder.AddAndModify(Enum_zwjKindofUpdate.Add);
                        }
                    }
                }
                else
                {
                    i_fail++;
                    myStringBuilder_err.Append(string.Format("\n身份证号码:{0}, 错误信息:{1}", myClass_KindofEmployerWelder.IdentificationCard, str_Err));
                }
            }
            this.RefreshData(false);
            MessageBox.Show(string.Format("操作完成,其中同步成功{0}条,添加{1}条,删除{2}条,失败{3}条,失败原因如下:\n{4}", i_success, i_success_add, i_success_delete, i_fail, myStringBuilder_err.ToString()));
        }