示例#1
0
        private void toolStripButton_JobIn_Click(object sender, EventArgs e)
        {
            FrmSalesList frmSales = new FrmSalesList();

            frmSales.OperationType = "调入";
            if (frmSales.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                JobOperation(frmSales);
            }
        }
示例#2
0
        private void JobOperation(FrmSalesList frmSales)
        {
            using (SqlConnection connection = SqlHelper.OpenConnection())
            {
                SqlTransaction sqlTran = connection.BeginTransaction();
                SqlCommand     cmd     = connection.CreateCommand();
                cmd.Transaction = sqlTran;

                try
                {
                    if (frmSales.OperationType == "复职")
                    {
                        cmd.CommandText = string.Format("update Sales Set OutDate = null, ProjectID = {0}, ProjectName = '{1}' where SalesID = {2}", Login.User.ProjectID, Login.User.ProjectName, frmSales.SalesID);
                        cmd.ExecuteNonQuery();
                    }

                    if (frmSales.OperationType == "调入")
                    {
                        cmd.CommandText = string.Format("update Sales Set ProjectID = {0}, ProjectName = '{1}' where SalesID = {2}", Login.User.ProjectID, Login.User.ProjectName, frmSales.SalesID);
                        cmd.ExecuteNonQuery();
                    }

                    cmd.CommandText = string.Format("insert into JobTrack (SalesID, SalesName, DeptID, DeptName, JobType, BeginDate, OperationType) values ({0},'{1}',{2},'{3}','{4}','{5}','{6}')",
                                                    frmSales.SalesID, frmSales.SalesName, treeView_Dept.SelectedNode.Name, treeView_Dept.SelectedNode.Text, frmSales.JobType, frmSales.OperationDate, frmSales.OperationType);

                    cmd.ExecuteNonQuery();

                    DataTable dt = (DataTable)dataGridView_Employe.DataSource;

                    DataRow dr = dt.NewRow();

                    dr["SalesID"]   = frmSales.SalesID;
                    dr["DeptID"]    = treeView_Dept.SelectedNode.Name;
                    dr["SalesName"] = frmSales.SalesName;
                    dr["DeptName"]  = treeView_Dept.SelectedNode.Text;
                    dr["BeginDate"] = frmSales.OperationDate;
                    dr["JobType"]   = frmSales.JobType;
                    dr["Phone"]     = frmSales.Phone;
                    dr["InDate"]    = frmSales.InDate;
                    dr["Position"]  = frmSales.Position;

                    dt.Rows.Add(dr);

                    sqlTran.Commit();

                    Prompt.Information("操作成功!");
                }
                catch (Exception ex)
                {
                    sqlTran.Rollback();
                    Prompt.Error("操作失败, 错误:" + ex.Message);
                }
            }
        }
示例#3
0
        private void toolStripButton_JobReturn_Click(object sender, EventArgs e)
        {
            //if (treeView_Dept.SelectedNode.Parent == null)
            //{
            //    Prompt.Warning("无法在项目根节点下操作,请选择部门节点!");
            //    return;
            //}

            FrmSalesList frmSales = new FrmSalesList();

            frmSales.OperationType = "复职";
            if (frmSales.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                JobOperation(frmSales);
            }
        }