Пример #1
0
        private void getTaskType()
        {
            Principal objPrinciapl  = AccountManagement.getUserPrincipal();
            String    tmpDepartment = AccountManagement.GetDepartment(objPrinciapl);
            string    cmdString     = "SELECT [TaskTypeName] ,[TaskTypeDescription] FROM [vwCapMyTask_TaskTypeList] where [DepartmentName] = @DepartmentValue";

            string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                using (SqlCommand comm = new SqlCommand())
                {
                    comm.Connection  = conn;
                    comm.CommandText = cmdString;
                    comm.Parameters.AddWithValue("@DepartmentValue", tmpDepartment);
                    conn.Open();

                    SqlDataAdapter adapter = new SqlDataAdapter(comm);

                    DataSet tmpDataset = new DataSet();

                    adapter.Fill(tmpDataset, "vwCapMyTask_TaskTypeList");

                    lstTask.DataSource    = tmpDataset.Tables["vwCapMyTask_TaskTypeList"];
                    lstTask.DisplayMember = "TaskTypeName";
                    lstTask.ValueMember   = "TaskTypeName";
                    //comm.Dispose();
                    //conn.Close();
                    //conn.Dispose();
                }
            }
        }
Пример #2
0
        public static Int32 getHeader(String User)
        {
            Int32 _iResult = 0;

            try
            {
                string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        string cmdString = "Select top 1 [ID] from [dbo].[TaskTracking] where DATEDIFF(DAY, [SubmittedDate], @val2) = 0 and [SubmittedBy] = @val3";

                        comm.Connection  = conn;
                        comm.CommandText = cmdString;
                        comm.Parameters.AddWithValue("@val3", User);
                        //comm.Parameters.AddWithValue("@val2", "DAY");
                        comm.Parameters.AddWithValue("@val2", DateTime.Today);
                        conn.Open();
                        SqlDataReader oReader = comm.ExecuteReader();

                        if (oReader.HasRows) // found record
                        {
                            // get ref number
                            oReader.Read();
                            _iResult = Convert.ToInt32(oReader["ID"].ToString());
                        }
                        else
                        {
                            oReader.Close();

                            Principal objPrinciapl  = AccountManagement.getUserPrincipal();
                            String    tmpDepartment = AccountManagement.GetDepartment(objPrinciapl);


                            // Create new record
                            cmdString        = "INSERT INTO [dbo].[TaskTracking] ([SubmittedBy],[SubmittedDate],[Status],[DepartmentID],[Manager]) VALUES (@SubmittedByVal, getdate(),@StatusVal,@DepartmentVal,@ManagerVal);SELECT SCOPE_IDENTITY();";
                            comm.CommandText = cmdString;
                            comm.Parameters.AddWithValue("@SubmittedByVal", Environment.UserDomainName + "\\" + Environment.UserName);
                            comm.Parameters.AddWithValue("@StatusVal", "Submitted");
                            comm.Parameters.AddWithValue("@DepartmentVal", tmpDepartment);
                            comm.Parameters.AddWithValue("@ManagerVal", getDepartmentManager(tmpDepartment));

                            _iResult = (Int32)comm.ExecuteNonQuery();
                        }

                        comm.Dispose();
                        conn.Close();
                        conn.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(_iResult);
        }
Пример #3
0
        public static bool saveToDB(String ImgPNGBase64, Int32 TaskTrackingID, String TaskType, String Comment, String User)
        {
            bool _bResult = false;

            try
            {
                String    DateText = getDateText();
                String    SerializedK2ImgBase64 = String.Format("<image><name>{0}</name><content>{1}</content></image>", User + "-" + TaskType + "-" + TaskTrackingID + DateText + ".Png", ImgPNGBase64);
                String    cmdString             = "INSERT INTO [dbo].[TaskTrackingItem]([TaskTrackingID],[TaskType],[Attachment],[Comment],[CommentOn],[Requestor],[SubmittedOn],[DepartmentID],[Manager],[Status]) VALUES (@val1, @val2, @val3, @val4, @val5, @val6, @val7, @val8, @val9, @val10)";
                String    tmpUser       = Environment.UserDomainName + "\\" + Environment.UserName;
                Principal objPrinciapl  = AccountManagement.getUserPrincipal();
                String    tmpDepartment = AccountManagement.GetDepartment(objPrinciapl);

                string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.Connection  = conn;
                        comm.CommandText = cmdString;
                        comm.Parameters.AddWithValue("@val1", TaskTrackingID);
                        comm.Parameters.AddWithValue("@val2", TaskType);
                        comm.Parameters.AddWithValue("@val3", SerializedK2ImgBase64);
                        comm.Parameters.AddWithValue("@val4", Comment);
                        comm.Parameters.AddWithValue("@val5", DateTime.Today);
                        comm.Parameters.AddWithValue("@val6", tmpUser);
                        comm.Parameters.AddWithValue("@val7", DateTime.Today);
                        comm.Parameters.AddWithValue("@val8", tmpDepartment);
                        comm.Parameters.AddWithValue("@val9", getDepartmentManager(tmpDepartment));
                        comm.Parameters.AddWithValue("@val10", "Waiting for Manager Approval");
                        conn.Open();
                        comm.ExecuteNonQuery();


                        comm.Dispose();
                        conn.Close();
                        conn.Dispose();
                    }
                }

                _bResult = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                _bResult = false;
            }


            return(_bResult);
        }