public int CreateIdea(Ideas Idea)
        {
            users         Rec  = new users();
            SqlConnection conn = new SqlConnection(connectionString);
            int           Ideaid;
            String        str = "Insert Into Idea(userid,courseid,Title,Description,category,currentprocess,Proposedsolution,Benfits,otherInformation,createdon,status,documentid) values(@userid,@courseId,@Title,@Description,@category,@currentprocess,@Proposedsolution,@Benfits,@otherInformation,@createdon,@status,@documentid);SELECT CAST(scope_identity() AS int)";
            SqlCommand    cmd = new SqlCommand(str, conn);

            cmd.Parameters.Add(new SqlParameter("@userid", (object)Login.id));
            cmd.Parameters.Add(new SqlParameter("@courseId", Login.Courseid == null ? (Object)DBNull.Value : Login.Courseid));
            cmd.Parameters.Add(new SqlParameter("@Title", (object)Idea.Title));
            cmd.Parameters.Add(new SqlParameter("@Description", (object)Idea.Description));
            cmd.Parameters.Add(new SqlParameter("@category", (object)Idea.category));
            cmd.Parameters.Add(new SqlParameter("@currentprocess", (object)Idea.currentprocess));
            cmd.Parameters.Add(new SqlParameter("@Proposedsolution", (object)Idea.Proposedsolution));
            cmd.Parameters.Add(new SqlParameter("@Benfits", (object)Idea.Benfits));
            cmd.Parameters.Add(new SqlParameter("@otherInformation", (object)Idea.otherInformation));
            cmd.Parameters.Add(new SqlParameter("@createdon", (object)Idea.createdon));
            cmd.Parameters.Add(new SqlParameter("@status", (object)Idea.status));
            cmd.Parameters.Add(new SqlParameter("@documentid", (object)Idea.documentid));

            try
            {
                conn.Open();
                Ideaid = (int)cmd.ExecuteScalar();
                conn.Close();
                return(Ideaid);
            }

            catch (Exception Ex)
            {
                MessageBox.Show("Error Occured:" + Ex.Message);
                return(0);
            }
        }
        private void IdeaReadOnly_Loaded(object sender, RoutedEventArgs e)
        {
            LblWish.Content = "WelCome " + Login.Name;
            string comp = "";

            Ideainfo = obj.IdeaDisplay(id);
            List <IdeaRecords>   colle = obj.GetIdeaInfo();
            IEnumerable <string> xx    = from rec in colle where rec.ideaid == id select rec.PendingWith;

            foreach (string Name in xx)
            {
                comp = Name;
            }
            if ((Login.role == "Aprover") && (comp.Equals(Login.Name)))
            {
                Gidonoff.Visibility = Visibility.Visible;
            }
            else
            {
                Gidonoff.Visibility = Visibility.Hidden;
            }

            if (Login.role == "Student")
            {
                Gidonoff.Visibility = Visibility.Hidden;
            }
            if (Ideainfo.documentid < 1)
            {
                BtnDownLoad.Visibility = Visibility.Hidden;
            }


            if (Ideainfo != null)
            {
                TxtTitle.Text = Ideainfo.Title;

                TxtBenfits.Text          = Ideainfo.Benfits;
                TxtCurrentProcess.Text   = Ideainfo.currentprocess;
                TxtProposedSolution.Text = Ideainfo.Proposedsolution;
                TxtDesc.Text             = Ideainfo.Description;
                CmbCategory.Text         = Ideainfo.category;

                TxtLevel1comments.Text = Ideainfo.comment1;
                TxtLevel2comments.Text = Ideainfo.comment2;
                Documentid             = Ideainfo.documentid;
            }
            LblWish.Content = "Welcome " + Login.Name;
        }
        public Ideas IdeaDisplay(int pideaid)
        {
            SqlConnection conn = new SqlConnection(connectionString);
            // String str = "Insert Into Users(Name,PassWord,Role,ValidFRom,ValidTo) values('"+user.Name+"','"+user.Password+"','"+user.Role+"','"+user.ValidFrom.Date +"','"+user.ValidTo.Date+ "')";
            String     str = "select ideaid,userid,courseid,title,description,category,currentprocess,Proposedsolution,Benfits,otherInformation,Documentid,comment1,comment2,createdon,status from Idea where ideaid=" + pideaid;
            SqlCommand cmd = new SqlCommand(str, conn);
            // MessageBox.Show(user.ValidFrom.Date.ToString());
            Ideas rec = new Ideas();

            try
            {
                conn.Open();
                SqlDataReader rd = cmd.ExecuteReader();

                rd.Read();
                if (rd.HasRows)
                {
                    // Ideas rec=new Ideas();
                    rec.IdeaId           = (int)rd["ideaid"];
                    rec.userid           = (int)rd["userid"];
                    rec.courseid         = (int)rd["courseId"];
                    rec.Title            = rd["title"].ToString();
                    rec.Description      = rd["description"].ToString();
                    rec.category         = rd["category"].ToString();
                    rec.currentprocess   = rd["currentprocess"].ToString();
                    rec.Proposedsolution = rd["Proposedsolution"].ToString();
                    rec.Benfits          = rd["Benfits"].ToString();
                    rec.otherInformation = rd["otherInformation"].ToString();
                    rec.createdon        = (DateTime)rd["createdon"];
                    rec.status           = rd["status"].ToString();
                    rec.comment1         = rd["comment1"].ToString();
                    rec.comment2         = rd["comment2"].ToString();
                    rec.documentid       = (int)rd["Documentid"];
                    conn.Close();
                }
                return(rec);
            }

            catch (Exception Ex)
            {
                MessageBox.Show("Error Occured:" + Ex.Message);
                return(null);
            }
        }
Exemple #4
0
        private void BtnSubmitIdea_Click(object sender, RoutedEventArgs e)
        {
            Ideas rec = new Ideas();

            // byte[] data=null;
            rec.Title            = TxtTitle.Text;
            rec.Description      = TxtDesc.Text;
            rec.category         = CmbCategory.Text;
            rec.currentprocess   = TxtCurrentProcess.Text;
            rec.Proposedsolution = TxtProposedSolution.Text;
            rec.Benfits          = TxtBenfits.Text;
            rec.otherInformation = TxtOtherInformations.Text;
            rec.status           = "Submited";
            rec.createdon        = DateTime.Now;


            if (Documentid > 0)
            {
                rec.documentid = Documentid;
            }

            if (TxtTitle.Text == "")
            {
                MessageBox.Show("Enter Title");
                return;
            }
            if (TxtDesc.Text == "")
            {
                MessageBox.Show("Enter Description");
                return;
            }
            //if (CmbCategory.SelectedValue == null)
            //{
            //    MessageBox.Show("Select category");
            //    return;
            //}
            if (TxtCurrentProcess.Text == "")
            {
                MessageBox.Show("Select CurrentProcess");
                return;
            }
            if (TxtProposedSolution.Text == "")
            {
                MessageBox.Show("Select PoposedSolution");
                return;
            }
            if (TxtBenfits.Text == "")
            {
                MessageBox.Show("Select Benfits");
                return;
            }

            Ideaid = Obj.CreateIdea(rec);
            MessageBox.Show("Idea " + Ideaid + " Created");
            Ideas IdeaRec = Obj.IdeaDisplay(Ideaid);



            IEnumerable <string> maillist = Obj.GetIdeaInfo().Where(x => x.ideaid == Ideaid).Select(x => x.Mailtoid);

            String Data = "Dear Approver," + Environment.NewLine
                          + "Below idea submitted by " + Login.Name + " is awaiting your approvals." + Environment.NewLine
                          + "Please review and provide your feedback." + Environment.NewLine
                          + "Idea#       " + Ideaid + Environment.NewLine
                          + " Idea Desc:  " + rec.Title;

            foreach (string temp in maillist)
            {
                Obj.SendMail(temp, Data);
            }


            this.Visibility = System.Windows.Visibility.Collapsed;
            MyIdea my = new MyIdea();

            my.ShowDialog();
        }