Ejemplo n.º 1
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     foreach (UnitParticle UP in unitParticles)
     {
         UP.Draw();
     }
 }
        private void LoadData()
        {
            try
            {
                string code = _boxCode;

                var a = from data in dbContext.tbl_BoxMaster
                        join boxSeries in dbContext.tbl_BoxSeries on data.BoxCode equals boxSeries.BoxCode
                        into UP
                        from boxSeries in UP.DefaultIfEmpty()
                        where data.BoxCode == code
                        orderby boxSeries.SeriesNo

                        select new
                {
                    BoxCode              = data.BoxCode,
                    SeriesNo             = boxSeries.SeriesNo,
                    IsDisposed           = boxSeries.IsDisposed,
                    IsUsed               = boxSeries.IsUsed,
                    IsIssuedToProduction = boxSeries.IsIssuedToProduction,
                    IsIssuedToWareHouse  = boxSeries.IsIssuedToWareHouse,
                    IsDelivered          = boxSeries.IsDelivered,
                    IsReturned           = boxSeries.IsReturned,
                    BoxSeriesCode        = boxSeries.BoxCode + "-" + boxSeries.SeriesNo
                };

                gridInventory.ItemsSource = a.ToList();

                GetCount();
            }
            catch
            {
            }
        }
        private void GetRequestDetails()
        {
            var a = (from data in dbContext.tblRequests
                     join incharge in dbContext.tblIncharges on data.Incharge_ID equals incharge.Incharge_ID
                     into UP
                     from incharge in UP.DefaultIfEmpty()
                     where data.JR_Code.Trim() == jrcode.Trim()
                     select new
            {
                Request_Date = data.Request_Date,
                EmpID = data.EmpID,
                InchargeCode = incharge.Incharge_ID,
                Incharge = incharge.Incharge,
                Customer = data.Customer,
                PartName = data.Partname,
                PartCode = data.Partcode,
                JigType = data.JigType,
                Quantity = data.Quantity,
                QtyProdPerHr = data.QtyProdPerHr,
                Monthly_Req = data.Monthly_Req,
                Machine_Capacity = data.Machine_Capacity,
                NextForecast = data.NextForeCast,
                Problem_Desc = data.Problem_Desc
            }
                     ).ToList();


            foreach (DataRow row in ConvertToDataTable(a).Rows)
            {
                userempid = row[1].ToString().Trim();
                incharge  = row[2].ToString().Trim();
            }

            GetRequestorDetails(userempid);
        }
Ejemplo n.º 4
0
        public override void OnHanlder(DataFlowContext context, Root parseObj)
        {
            if (parseObj.data == null)
            {
                return;
            }

            var upId = int.Parse(parseObj.data.card.mid);    // 额,理论上是数字id

            using var db = DBSet.GetCon(DBSet.SqliteDBName.Bilibili);
            var up = db.SingleById <UP>(upId);

            if (up == null)
            {
                // 没有up主信息,则新建,否则只是复制数据
                up    = new UP();
                up.Id = upId;
                db.Insert(up);
            }
            var data = parseObj.data.card;

            up.following = data.fans;
            up.follower  = data.attention;
            up.friend    = data.friend;
            up.video     = parseObj.data.archive_count;
            up.name      = data.name;
            up.sex       = data.sex;
            up.face      = data.face;
            up.sign      = data.sign;
            up.level     = data.level_info.current_level;

            db.Update(up);
        }
Ejemplo n.º 5
0
        private void bunifuFlatButton3_Click(object sender, EventArgs e)
        {
            //---------------------------- ---------------------------------------------------------
            SqlDataReader ddr;
            SqlCommand    ccmd = new SqlCommand("select Priv_Display from TB_Priv where Priv_User_ID=" + Convert.ToInt32(Program.user_ID) + " and Priv_Screen_ID=21", con);

            con.Open();
            ddr = ccmd.ExecuteReader();
            if (ddr.Read())
            {
                if (ddr["Priv_Display"].ToString() == "True")
                {
                    UP ssa = new UP();
                    addControlsTopanel(ssa);
                }
                else
                {
                    MessageBox.Show("عذرا لا يوجد لديك صلاحية للدخول الى هذه الشاشة", "الصلاحيات 21", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            ddr.Close();
            con.Close();

            //---------------------------------------------------------------------------------------
        }
Ejemplo n.º 6
0
    bool display         = false;   //プレイヤーがクリックされた際の表示非表示を切り替えるための変数

    // Use this for initialization
    void Start()
    {
        //-----------------------------------------------------------------------------------------------------------------
        //当たり判定オブジェクト取得
        //-----------------------------------------------------------------------------------------------------------------
        Up    = GameObject.Find("Player/Up");
        Down  = GameObject.Find("Player/Down");
        Right = GameObject.Find("Player/Right");
        Left  = GameObject.Find("Player/Left");

        //-----------------------------------------------------------------------------------------------------------------
        //当たり判定のスクリプト取得
        //-----------------------------------------------------------------------------------------------------------------
        Uscript = GameObject.Find("Up").GetComponent <UP>();
        Dscript = GameObject.Find("Down").GetComponent <DOWN>();
        Rscript = GameObject.Find("Right").GetComponent <RIGHT>();
        Lscript = GameObject.Find("Left").GetComponent <LEFT>();

        //-----------------------------------------------------------------------------------------------------------------
        //矢印オブジェクト取得
        //-----------------------------------------------------------------------------------------------------------------
        UpArrow    = GameObject.Find("UpArrow");
        DownArrow  = GameObject.Find("DownArrow");
        RightArrow = GameObject.Find("RightArrow");
        LeftArrow  = GameObject.Find("LeftArrow");

        //-----------------------------------------------------------------------------------------------------------------
        //初期化
        //-----------------------------------------------------------------------------------------------------------------
        Ctrigger  = false;   //クリック判定初期化
        direction = 0;       //向き変数の初期化
    }
Ejemplo n.º 7
0
        public ActionResult Delete(short id = 0)
        {
            UP up = db.UPs.Find(id);

            if (up == null)
            {
                return(HttpNotFound());
            }
            return(View(up));
        }
Ejemplo n.º 8
0
        public ActionResult Edit(short id = 0)
        {
            UP up = db.UPs.Find(id);

            if (up == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BONDERID = new SelectList(db.BONDERs, "BONDERSLNO", "BONDERSLNO", up.BONDERID);
            return(View(up));
        }
Ejemplo n.º 9
0
 public ActionResult Edit(UP up)
 {
     if (ModelState.IsValid)
     {
         db.Entry(up).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BONDERID = new SelectList(db.BONDERs, "BONDERSLNO", "BONDERSLNO", up.BONDERID);
     return(View(up));
 }
Ejemplo n.º 10
0
        public static (double, double) task1(UP up)
        {
            double x = 0;

            (double, double)tuple = (0, 0);
            for (double i = -1; i <= 0; i += 0.2)
            {
                x    += 0.2;
                tuple = up(x);
            }
            return(tuple);
        }
Ejemplo n.º 11
0
        public int Add_User(string account, string upwd, int a)
        {
            UP up = new UP
            {
                UP_account   = account,
                UP_password  = upwd,
                UP_detail_id = a
            };

            db.UP.Add(up);
            return(db.SaveChanges());
        }
Ejemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        //gameObject.GetComponentInParent<HingeJoint>();
        Camera cam = SelectCam.GetComponent <Camera>();

        Vector3    mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
        Collider2D col      = Physics2D.OverlapPoint(mousePos);

        if (Input.GetMouseButtonDown(0))
        {
            //右に移動
            foreach (GameObject Right in right)
            {
                if (col == Right.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(this.transform.position.x + 40, this.transform.position.y, -10);
                }
            }
            //左に移動
            foreach (GameObject Left in left)
            {
                if (col == Left.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(this.transform.position.x - 40, this.transform.position.y, -10);
                }
            }
            //上に移動
            foreach (GameObject UP in up)
            {
                if (col == UP.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(0, 0, -10);
                }
            }
            //下に移動
            foreach (GameObject Down in down)
            {
                if (col == Down.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(0, -20, -10);
                }
            }
            //タイトルへ戻る
            foreach (GameObject Back in back)
            {
                if (col == Back.GetComponent <GameObject>())
                {
                    Application.LoadLevel("0");
                    //Scene0 = Title.name
                }
            }
        }
    }
Ejemplo n.º 13
0
 public void UpdateProgress(int progress)
 {
     if (DownloadProgressBar.InvokeRequired)
     {
         UP d = UpdateProgress;
         this.Invoke(d, new object[] { progress });
     }
     else
     {
         DownloadProgressBar.Value = progress;
     }
 }
Ejemplo n.º 14
0
        public ActionResult DeleteConfirmed(short id)
        {
            var childData = db.UPREQUESTLISTs.Where(r => r.UPID == id).ToList();

            foreach (var data in childData)
            {
                db.UPREQUESTLISTs.Remove(data);
            }
            UP up = db.UPs.Find(id);

            TempData["Message"] = string.Format("UP deleted successfully, Which UP No was {0}", up.UPNO);
            db.UPs.Remove(up);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            //通过传参拿到父类
            Computer            cpu  = new Computer();
            MobileStorageDevice disk = new MobileDisk();
            MobileStorageDevice mp3  = new MP3();
            MobileStorageDevice up   = new UP();

            cpu.CpuRead(disk);
            cpu.CpuWrite(disk);
            cpu.CpuRead(mp3);
            cpu.CpuWrite(mp3);
            cpu.CpuRead(up);
            cpu.CpuWrite(up);
            Console.ReadKey();
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Update the progress bar percentage.
 /// </summary>
 /// <param name="progress">Percentage to set the progress bar to.</param>
 private void UpdateProgress(int progress)
 {
     if (IsDisposed || DownloadProgressBar.IsDisposed)
     {
         return;
     }
     if (DownloadProgressBar.InvokeRequired)
     {
         UP d = UpdateProgress;
         try {
             Invoke(d, new object[] { progress });
         } catch (ObjectDisposedException) { }
     }
     else if (progress >= 0)
     {
         DownloadProgressBar.Value = progress;
     }
 }
Ejemplo n.º 17
0
        public static int MonLength(int[] arr, UP up)
        {
            int temp = 1;
            int res  = 0;

            foreach (int i in arr)
            {
                if (up(i))
                {
                    ++temp;
                }
                else if (res < temp)
                {
                    res  = temp;
                    temp = 1;
                }
            }
            return(res);
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            //通过属性拿到父类
            Computer            cpu  = new Computer();
            MobileStorageDevice disk = new MobileDisk();
            MobileStorageDevice mp3  = new MP3();
            MobileStorageDevice up   = new UP();

            cpu.Ms = disk;
            cpu.CpuRead();
            cpu.CpuWrite();
            cpu.Ms = mp3;
            cpu.CpuRead();
            cpu.CpuWrite();
            cpu.Ms = up;
            cpu.CpuRead();
            cpu.CpuWrite();
            Console.ReadKey();
        }
Ejemplo n.º 19
0
 private void LoginB_Click(object sender, RoutedEventArgs e)
 {
     if (UN.Text != "" || UP.Password != "")
     {
         AccountsTable.UserName     = UN.Text;
         AccountsTable.UserPassword = Kernel.Core.GetSHAHashData(UP.Password);
         if (AccountsTable.UserLogin())
         {
             CP cp = new CP();
             cp.Show();
             this.Hide();
         }
         else
         {
             UP.Focus();
         }
     }
     else
     {
         MessageBox.Show("ادخل اسم المستخدم او كلمه المرور", "خطا", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 20
0
    public void InitCreepParameter(List <UnitCreep> list)
    {
        //~ Debug.Log("init creep    "+creepParameter.Length);

        UnitParameter[] temp = new UnitParameter[list.Count];

        for (int i = 0; i < list.Count; i++)
        {
            bool match = false;
            //~ Debug.Log(list[i].gameObject);
            //~ for(int j=0; j<creepParameter.Length; i++){
            foreach (UnitParameter UP in creepParameter)
            {
                //~ UnitParameter UP=creepParameter[j];
                if (UP.unit = list[i].gameObject)
                {
                    temp[i] = UP.Clone();
                    match   = true;
                    break;
                }
            }

            if (!match)
            {
                temp[i]      = new UnitParameter();
                temp[i].unit = list[i].gameObject;
            }
        }

        creepParameter = temp;
        //~ creepParameter=new UnitParameter[temp.Length];
        //~ for(int i=0; i<temp.Length; i++){
        //~ creepParameter[i]=temp[i];
        //~ }

        //~ for(int i=0; i<temp.Length; i++){
        //~ Debug.Log(i+"   obj:"+temp[i].unit+"   "+list[i].gameObject);
        //~ }
    }
Ejemplo n.º 21
0
 private void LoginB_Click_1(object sender, EventArgs e)
 {
     if (UN.Text == "")
     {
         MessageBox.Show("لم تدخل اسم المستخدم");
     }
     else if (UP.Text == "")
     {
         MessageBox.Show("لم تدخل كلمه المرور");
     }
     else
     {
         AccountsTable.UserName     = UN.Text;
         AccountsTable.UserPassword = Program.GetSHAHashData(UP.Text);
         if (AccountsTable.UserLogin())
         {
             this.Hide();
         }
         else
         {
             UP.Focus();
         }
     }
 }
Ejemplo n.º 22
0
        protected void Approve(object sender, EventArgs e)
        {
            string link = string.Empty, body = string.Empty;

            link = Environment.NewLine + "http://" + HttpContext.Current.Request.Url.Authority + "/"
                   + ConfigurationManager.AppSettings["ApproverPage"];

            var asstr = (from data in dbContext.tblUsers
                         join approvers in dbContext.tblApprovers on data.EmpID equals approvers.EmpID
                         into UP
                         from approvers in UP.DefaultIfEmpty()
                         where approvers.OrderValue == 1
                         select new
            {
                EmpID = data.EmpID,
                EmailAdd = data.EmailAdd
            }
                         ).ToList();

            var asstr2 = (from data in dbContext.tblUsers
                          join approvers in dbContext.tblApprovers on data.EmpID equals approvers.EmpID
                          into UP
                          from approvers in UP.DefaultIfEmpty()
                          where approvers.OrderValue == 1
                          select new
            {
                EmpID = data.EmpID,
                EmailAdd = data.EmailAdd
            }
                          ).ToList();

            string appempid = string.Empty;

            foreach (DataRow dr in ConvertToDataTable(asstr2).Rows)
            {
                appempid = dr["EmpID"].ToString().Trim();
            }

            var dbuser = dbHRISContext.SKPI_GetAllEmployeesByEmpID(appempid.Trim()).ToList();

            if (ConvertToDataTable(dbuser).Rows.Count > 0)
            {
                foreach (DataRow row in ConvertToDataTable(dbuser).Rows)
                {
                    nextApprover = row["FullName_FnameFirst"].ToString().Trim();
                }
            }

            var app = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

            if (app != null)
            {
                app.Is_Noted = true;

                app.Noter = approverfullname_fnamefirst.ToString();

                app.NoterRemarks = "SIGNED";

                app.DateNoted = DateTime.Now.Date;

                app.IsHold = false;

                app.Manager = nextApprover.Trim();

                app.IsSentToApprover_First = true;

                app.CreationDateTime = DateTime.Now;

                dbContext.Entry(app).State = EntityState.Modified;

                dbContext.SaveChanges();
            }


            foreach (DataRow dr in ConvertToDataTable(asstr).Rows)
            {
                Boolean ress;

                ress = SaveEmailLogs(link + "?EmpID=" + dr["EmpID"].ToString().Trim() + "&RCode=" + Session["RCode"].ToString().Trim(), "Approver", dr["EmailAdd"].ToString().Trim(), Session["FullName_LnameFirst"].ToString().Trim()
                                     , dr["EmpID"].ToString().Trim(), Session["RCode"].ToString().Trim());

                body = "Dear Sir/Ma'am," + "<br /><br />" + "Good Day!";

                body += "<br /><br />" + "I Have Prepared A Job Order Request For Your Checking And Approval.";

                body += "<br /><br />" + "You may click the link below to redirect to main page. ";

                body += "<br /><br />" + link + "?EmpID=" + dr["EmpID"].ToString().Trim() + "&RCode=" + Session["RCode"].ToString().Trim();

                body += "<br /><br />" + "Thank You.";

                body += "<br /><br />" + "Note: This is a system generated email. Please do not reply. Thank you";

                var rx = new Regex(@"(?<=\w)\w");

                var newString2 = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                using (MailMessage mm = new MailMessage())
                {
                    string sub = "Online Job Order Request: Requesting For Approval";

                    mm.Subject = sub.ToUpper();

                    mm.Body = body;

                    var newString = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                    mm.From = new MailAddress(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),

                                              ConfigurationManager.AppSettings["MailSenderName"].ToString());

                    mm.To.Add(dr["EmailAdd"].ToString().Trim());

                    SmtpClient smtp = new SmtpClient();

                    smtp.Host = ConfigurationManager.AppSettings["MailServer"].ToString();

                    smtp.EnableSsl = true;

                    mm.IsBodyHtml = true;

                    NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),
                                                                          ConfigurationManager.AppSettings["MailSenderEmailPassword"].ToString());

                    smtp.Credentials = NetworkCred;

                    smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);

                    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate,
                                                                                       X509Chain chain, SslPolicyErrors sslPolicyErrors)
                    { return(true); };
                    smtp.Send(mm);
                }
            }

            SendToRequestor();

            divSuccess.Visible = true;

            divApplication.Visible = false;
        }
        private void Save()
        {
            if (tbQty.Value <= 0)
            {
                MessageBox.Show("Enter Quantity");

                tbQty.Value = 0;

                tbQty.Focus();
            }
            else if (!recDate.SelectedDate.HasValue)
            {
                MessageBox.Show("Purchased date is required");
                recDate.Focus();
            }
            else
            {
                int?maxCount = dbContext.tbl_BoxSeries.Where(p => p.BoxCode == _boxCode).Select(p => p.SeriesNo).DefaultIfEmpty(0).Max();

                int count = maxCount.GetValueOrDefault() + 1;

                if (maxCount.GetValueOrDefault() == 0)
                {
                    for (int i = count; i <= tbQty.Value; i++)
                    {
                        //MessageBox.Show(i.ToString());

                        tbl_BoxSeries _tb2 = new tbl_BoxSeries()
                        {
                            BoxCode = _boxCode,

                            SeriesNo = i,

                            IsDisposed = false,

                            IsUsed = false,

                            IsDelivered = false,

                            IsReturned = false,

                            IsIssuedToProduction = false,

                            IsIssuedToWareHouse = false,

                            EncodedBy = _name,

                            DateEncoded = DateTime.Now
                        };

                        dbContext.tbl_BoxSeries.Add(_tb2);


                        tbl_PurchasedHistory tbldata = new tbl_PurchasedHistory()
                        {
                            ItemCode      = _boxCode + "-" + i.ToString(),
                            DatePurchased = recDate.SelectedDate.Value
                        };

                        dbContext.tbl_PurchasedHistory.Add(tbldata);
                    }

                    dbContext.SaveChanges();
                }
                else
                {
                    for (int i = maxCount.GetValueOrDefault() + 1; i <= maxCount.GetValueOrDefault() + tbQty.Value; i++)
                    {
                        tbl_BoxSeries _tb2 = new tbl_BoxSeries()
                        {
                            BoxCode = _boxCode,

                            SeriesNo = i,

                            IsDisposed = false,

                            IsUsed = false,

                            IsDelivered = false,

                            IsReturned = false,

                            IsIssuedToProduction = false,

                            IsIssuedToWareHouse = false,

                            EncodedBy = _name,

                            DateEncoded = DateTime.Now
                        };

                        dbContext.tbl_BoxSeries.Add(_tb2);


                        tbl_PurchasedHistory tbldata = new tbl_PurchasedHistory()
                        {
                            ItemCode      = _boxCode + "-" + i.ToString(),
                            DatePurchased = recDate.SelectedDate.Value
                        };

                        dbContext.tbl_PurchasedHistory.Add(tbldata);
                    }

                    dbContext.SaveChanges();
                }

                var a = from data in dbContext.tbl_BoxMaster
                        join boxSeries in dbContext.tbl_BoxSeries on data.BoxCode equals boxSeries.BoxCode
                        into UP
                        from boxSeries in UP.DefaultIfEmpty()
                        where data.BoxCode == _boxCode
                        orderby boxSeries.SeriesNo

                        select new
                {
                    BoxCode              = data.BoxCode,
                    SeriesNo             = boxSeries.SeriesNo,
                    IsDisposed           = boxSeries.IsDisposed,
                    IsUsed               = boxSeries.IsUsed,
                    IsIssuedToProduction = boxSeries.IsIssuedToProduction,
                    IsIssuedToWareHouse  = boxSeries.IsIssuedToWareHouse,
                    IsDelivered          = boxSeries.IsDelivered,
                    IsReturned           = boxSeries.IsReturned,
                    BoxSeriesCode        = boxSeries.BoxCode + "-" + boxSeries.SeriesNo
                };

                string empname = string.Empty;

                var empdata = dbHRIS.SKPI_GetAllEmployeesByEmpID(_empID).ToList();

                foreach (DataRow dr in ConvertToDataTable(empdata).Rows)
                {
                    empname = dr["FullName_LnameFirst"].ToString();
                }

                tbl_TransactionMaster transact = new tbl_TransactionMaster()
                {
                    TransactBy         = empname,
                    TransactionDetails = "Encoded New Box Series Quantity",
                    CreationDateTime   = DateTime.Now
                };

                dbContext.tbl_TransactionMaster.Add(transact);

                dbContext.SaveChanges();

                MessageBox.Show("Quantity successfully added");

                tbQty.Value = 0;

                tbQty.Focus();

                LoadData();
            }
        }
Ejemplo n.º 24
0
 //Invoke publikuje tego eventa, robi, że jest możliwe użycie go
 public void Up()
 {
     UP.Invoke(this, EventArgs.Empty);
 }
        private void GetRequestDetails()
        {
            string remarksRejected = string.Empty;

            var a = (from data in dbContext.tblRequests
                     join incharge in dbContext.tblIncharges on data.Incharge_ID equals incharge.Incharge_ID
                     join assess in dbContext.tblAssessments on data.AssessmentCode equals assess.AssessmentCode
                     into UP
                     from assess in UP.DefaultIfEmpty()
                     where data.JR_Code.Trim() == jrcode.Trim()
                     select new
            {
                Request_Date = data.Request_Date,
                EmpID = data.EmpID,
                InchargeCode = incharge.Incharge_ID,
                Incharge = incharge.Incharge,
                Customer = data.Customer,
                PartName = data.Partname,
                PartCode = data.Partcode,
                JigType = data.JigType,
                Quantity = data.Quantity,
                QtyProdPerHr = data.QtyProdPerHr,
                Monthly_Req = data.Monthly_Req,
                Machine_Capacity = data.Machine_Capacity,
                NextForecast = data.NextForeCast,
                Problem_Desc = data.Problem_Desc,
                AssessmentCode = data.AssessmentCode,
                AssessmentDesc = assess.Assessment,
                AssessmentRemarks = data.AssessmentRemarks,
                IsRejected = data.IsRejected,
                IsCancelled = data.IsCancelled,
                Checker = data.Checker,
                AssessBy = data.AssessedBy,
                Noter = data.Noter,
                Manager = data.Manager,
                AcceptBy = data.FinalAcceptanceBy,
                PreparerRemarks = data.Req_Remarks,
                CheckerRemarks = data.CheckerRemarks,
                AssesstorRemarks = data.AssessedRemarks,
                NoterRemarks = data.NoterRemarks,
                ApproverRemarks = data.ManagerRemarks,
                ReceiverRemarks = data.AcceptRemarks,
                RejectRemarks = data.RejectRemarks,
                DateChecked = data.DateChecked,
                DateAssessed = data.DateAssessed,
                DateNoted = data.DateNoted,
                DateApprove = data.DateApproved,
                DateReceived = data.DateAccepted,
                IsExistingJig = data.IsExistingJig
            }
                     ).ToList();


            foreach (DataRow row in ConvertToDataTable(a).Rows)
            {
                tbdateRequest.Text   = Convert.ToDateTime(row[0]).ToString("dd") + "-" + Convert.ToDateTime(row[0]).ToString("MMM") + "-" + Convert.ToDateTime(row[0]).ToString("yyyy");
                userempid            = row[1].ToString().Trim();
                incharge             = row[2].ToString().Trim();
                tbItemName.Text      = row[5].ToString();
                tbItemQuantity.Text  = row[8].ToString();
                tbCustomer.Text      = row[4].ToString();
                tbPartName.Text      = row[5].ToString();
                tbPartCode.Text      = row[6].ToString();
                tbTypeOfJig.Text     = row[7].ToString();
                tbQuantity_Jigs.Text = row[8].ToString();
                qtyhrtxt.Text        = row[9].ToString();
                mreqtxt.Text         = row[10].ToString();
                mcaptxt.Text         = row[11].ToString();
                tbNextForecast.Text  = row[12].ToString();
                tbjustification.Text = row[13].ToString().Replace("&nbsp;", " ").Replace("<br/>", "\r\n");

                tbAssessment.Text = row[15].ToString().Trim();

                //if (row[14].ToString().Trim() == "CP")
                //{
                //    tbAssessmentRemarks.Text = row[16].ToString().Trim();
                //    colAssessRemarks.Visible = true;
                //}
                //else
                //{
                //    tbAssessmentRemarks.Text = "N/A";
                //    colAssessRemarks.Visible = false;
                //}

                if (string.IsNullOrEmpty(row[16].ToString().Trim()))
                {
                    tbAssessmentRemarks.Text = "N/A";
                }
                else
                {
                    tbAssessmentRemarks.Text = row[16].ToString().Trim();
                }

                if (row.IsNull(36))
                {
                    tbIsExistingJig.Text = "N/A";
                }
                else
                {
                    if (Convert.ToBoolean(row[36]) == true)
                    {
                        tbIsExistingJig.Text = "Yes";
                    }
                    else
                    {
                        tbIsExistingJig.Text = "No";
                    }
                }

                if (Convert.ToBoolean(row[17]) == true && Convert.ToBoolean(row[18]) == false)
                {
                    rowRejected.Visible = true;

                    rowCancelled.Visible = false;

                    remarksRejected = "This request has been rejected. <br /> See below details:";

                    remarksRejected += "<br />" + "<br />" + "\"" + row[30].ToString().Replace("&nbsp;", " ").Replace("<br />", "\r\n") + "\"";

                    lblRemarks.Text = remarksRejected;
                }
                else if (Convert.ToBoolean(row[17]) == false && Convert.ToBoolean(row[18]) == true)
                {
                    rowRejected.Visible = false;

                    rowCancelled.Visible = true;
                }
                else
                {
                    rowRejected.Visible  = false;
                    rowCancelled.Visible = false;
                }

                //Preparer.InnerText = tbReqName.Text.Trim();

                Checker.InnerText = row[19].ToString().Trim();

                Assesstor.InnerText = row[20].ToString().Trim();

                Noter.InnerText = row[21].ToString().Trim();

                Approver.InnerText = row[22].ToString().Trim();

                Receiver.InnerText = row[23].ToString().Trim();

                lblPreparerRemarks.InnerText = row[24].ToString().Trim();

                lblCheckerRemarks.InnerText = row[25].ToString().Trim();

                lblAssesstorRemarks.InnerText = row[26].ToString().Trim();

                lblNoterRemarks.InnerText = row[27].ToString().Trim();

                lblApproverRemarks.InnerText = row[28].ToString().Trim();

                lblReceiverRemarks.InnerText = row[29].ToString().Trim();

                lblDateSigned_Preparer.InnerText = string.IsNullOrEmpty(row[0].ToString()) ? string.Empty : Convert.ToDateTime(row[0]).ToString("yyyy-MMM-dd");

                lblDateSigned_Checker.InnerText = string.IsNullOrEmpty(row[31].ToString()) ? string.Empty : Convert.ToDateTime(row[31]).ToString("yyyy-MMM-dd");

                lblDateSigned_Assesstor.InnerText = string.IsNullOrEmpty(row[32].ToString()) ? string.Empty : Convert.ToDateTime(row[32]).ToString("yyyy-MMM-dd");

                lblDateSigned_Noter.InnerText = string.IsNullOrEmpty(row[33].ToString()) ? string.Empty : Convert.ToDateTime(row[33]).ToString("yyyy-MMM-dd");

                lblDateSigned_Approver.InnerText = string.IsNullOrEmpty(row[34].ToString()) ? string.Empty : Convert.ToDateTime(row[34]).ToString("yyyy-MMM-dd");

                lblDateSigned_Receiver.InnerText = string.IsNullOrEmpty(row[35].ToString()) ? string.Empty : Convert.ToDateTime(row[35]).ToString("yyyy-MMM-dd");
            }

            SQLDSGetAttachment.ConnectionString = ClsConfig.JobRequestConnectionString;

            if (incharge == "01" || incharge == "02" || incharge == "03")
            {
                rdoInCharge.SelectedValue = "07";
            }
            else if (incharge == "04" || incharge == "05" || incharge == "06")
            {
                rdoInCharge.SelectedValue = "08";
            }
            else
            {
                rdoInCharge.SelectedValue = incharge;
            }

            GetRequestorDetails(userempid);

            GetTypeOfRequest(Request.QueryString["RCode"].ToString().Trim());

            if (rdoInCharge.SelectedValue == "04" || rdoInCharge.SelectedValue == "05" || rdoInCharge.SelectedValue == "08")
            {
                rowJigs.Visible       = true;
                rowFacilities.Visible = false;
            }
            else
            {
                rowJigs.Visible       = false;
                rowFacilities.Visible = true;
            }
        }
Ejemplo n.º 26
0
        protected void Approve(object sender, EventArgs e)
        {
            string link = string.Empty, body = string.Empty, jono = string.Empty;

            var app = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

            if (app != null)
            {
                app.JRF_No = GenerateJONumber().Trim();

                app.Is_Approved = true;

                app.Manager = approverfullname_fnamefirst.ToString();

                app.ManagerRemarks = "SIGNED";

                app.DateApproved = DateTime.Now.Date;

                app.IsHold = false;

                app.CreationDateTime = DateTime.Now;

                dbContext.Entry(app).State = EntityState.Modified;

                dbContext.SaveChanges();
            }

            link = Environment.NewLine + "http://" + HttpContext.Current.Request.Url.Authority + "/AdminHomeDirect.aspx";

            var asstr = (from data in dbContext.tblUsers
                         join inchargePerson in dbContext.tblInchargePersons on data.EmpID equals inchargePerson.EmpID
                         into UP
                         from inchargePerson in UP.DefaultIfEmpty()
                         where inchargePerson.Incharge_ID == rdoInCharge.SelectedValue && inchargePerson.IsAssesstor == true
                         select new
            {
                EmpID = data.EmpID,
                EmailAdd = data.EmailAdd,
                InchargeCode = inchargePerson.Incharge_ID,
                IsAssesstor = inchargePerson.IsAssesstor,
                IsNoter = inchargePerson.IsNoter
            }
                         ).ToList();

            foreach (DataRow dr in ConvertToDataTable(asstr).Rows)
            {
                body = "Dear Sir/Ma'am," + "<br /><br />" + "Good Day!";

                body += "<br /><br />" + "Please be informed that you have a new job order request ready for project acceptance.";

                body += "<br /><br />" + "You may click the link below to redirect to main page. ";

                body += "<br /><br />" + link + "?EmpID=" + dr["EmpID"].ToString().Trim();

                body += "<br /><br />" + "Thank You.";

                body += "<br /><br />" + "Note: This is a system generated email. Please do not reply. Thank you";

                var rx = new Regex(@"(?<=\w)\w");

                var newString2 = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                using (MailMessage mm = new MailMessage())
                {
                    string sub = "Online Job Order Request: New Job Order Request Ready For Project Acceptance";

                    mm.Subject = sub.ToUpper();

                    mm.Body = body;

                    var newString = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                    mm.From = new MailAddress(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),

                                              ConfigurationManager.AppSettings["MailSenderName"].ToString());

                    mm.To.Add(dr["EmailAdd"].ToString().Trim());

                    SmtpClient smtp = new SmtpClient();

                    smtp.Host = ConfigurationManager.AppSettings["MailServer"].ToString();

                    smtp.EnableSsl = true;

                    mm.IsBodyHtml = true;

                    NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),
                                                                          ConfigurationManager.AppSettings["MailSenderEmailPassword"].ToString());

                    smtp.Credentials = NetworkCred;

                    smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);

                    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate,
                                                                                       X509Chain chain, SslPolicyErrors sslPolicyErrors)
                    { return(true); };
                    smtp.Send(mm);
                }
            }

            //var noter = (from data in dbContext.tblUsers
            //             join inchargePerson in dbContext.tblInchargePersons on data.EmpID equals inchargePerson.EmpID
            //             into UP
            //             from inchargePerson in UP.DefaultIfEmpty()
            //             where inchargePerson.Incharge_ID == rdoInCharge.SelectedValue && inchargePerson.IsNoter == true
            //             select new
            //             {
            //                 EmpID = data.EmpID,
            //                 EmailAdd = data.EmailAdd,
            //                 InchargeCode = inchargePerson.Incharge_ID,
            //                 IsAssesstor = inchargePerson.IsAssesstor,
            //                 IsNoter = inchargePerson.IsNoter
            //             }
            //         ).ToList();

            //foreach (DataRow dr in ConvertToDataTable(noter).Rows)
            //{
            //    body = "Dear Sir/Ma'am," + "<br /><br />" + "Good Day!";

            //    body += "<br /><br />" + "Please be informed that you have a new job order request.";

            //    body += "<br /><br />" + "You may click the link below to redirect to main page. ";

            //    body += "<br /><br />" + link;

            //    body += "<br /><br />" + "Thank You.";

            //    body += "<br /><br />" + "Note: This is a system generated email. Please do not reply. Thank you";

            //    var rx = new Regex(@"(?<=\w)\w");

            //    var newString2 = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

            //    using (MailMessage mm = new MailMessage())
            //    {
            //        string sub = "Online Job Order Request: New Job Order Request";

            //        mm.Subject = sub.ToUpper();

            //        mm.Body = body;

            //        var newString = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

            //        mm.From = new MailAddress(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),

            //            ConfigurationManager.AppSettings["MailSenderName"].ToString());

            //        mm.To.Add(dr["EmailAdd"].ToString().Trim());

            //        SmtpClient smtp = new SmtpClient();

            //        smtp.Host = ConfigurationManager.AppSettings["MailServer"].ToString();

            //        smtp.EnableSsl = true;

            //        mm.IsBodyHtml = true;

            //        NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),
            //            ConfigurationManager.AppSettings["MailSenderEmailPassword"].ToString());

            //        smtp.Credentials = NetworkCred;

            //        smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);

            //        ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate,
            //                                                                    X509Chain chain, SslPolicyErrors sslPolicyErrors)
            //        { return true; };
            //        smtp.Send(mm);
            //    }
            //}

            SendToRequestor();

            divSuccess.Visible = true;

            divApplication.Visible = false;
        }
Ejemplo n.º 27
0
        private void GetRequestDetails()
        {
            string remarksHold = string.Empty;

            var a = (from data in dbContext.tblRequests
                     join incharge in dbContext.tblIncharges on data.Incharge_ID equals incharge.Incharge_ID
                     into UP
                     join assess in dbContext.tblAssessments on data.AssessmentCode equals assess.AssessmentCode
                     from incharge in UP.DefaultIfEmpty()
                     where data.JR_Code.Trim() == jrcode.Trim()
                     select new
            {
                Request_Date = data.Request_Date,
                EmpID = data.EmpID,
                InchargeCode = incharge.Incharge_ID,
                Incharge = incharge.Incharge,
                Customer = data.Customer,
                PartName = data.Partname,
                PartCode = data.Partcode,
                JigType = data.JigType,
                Quantity = data.Quantity,
                QtyProdPerHr = data.QtyProdPerHr,
                Monthly_Req = data.Monthly_Req,
                Machine_Capacity = data.Machine_Capacity,
                NextForecast = data.NextForeCast,
                Problem_Desc = data.Problem_Desc,
                AssessmentCode = data.AssessmentCode,
                AssessmentDesc = assess.Assessment,
                AssessmentRemarks = data.AssessmentRemarks,
                HoldRemarks = data.HoldRemarks,
                IsHold = data.IsHold,
                HoldBy = data.HoldBy,
                IsExistingJig = data.IsExistingJig
            }
                     ).ToList();


            foreach (DataRow row in ConvertToDataTable(a).Rows)
            {
                tbdateRequest.Text   = Convert.ToDateTime(row[0]).ToString("dd") + "-" + Convert.ToDateTime(row[0]).ToString("MMM") + "-" + Convert.ToDateTime(row[0]).ToString("yyyy");
                userempid            = row[1].ToString().Trim();
                incharge             = row[2].ToString().Trim();
                tbItemName.Text      = row[5].ToString();
                tbItemQuantity.Text  = row[8].ToString();
                tbCustomer.Text      = row[4].ToString();
                tbPartName.Text      = row[5].ToString();
                tbPartCode.Text      = row[6].ToString();
                tbTypeOfJig.Text     = row[7].ToString();
                tbQuantity_Jigs.Text = row[8].ToString();
                qtyhrtxt.Text        = row[9].ToString();
                mreqtxt.Text         = row[10].ToString();
                mcaptxt.Text         = row[11].ToString();
                tbNextForecast.Text  = row[12].ToString();
                tbjustification.Text = row[13].ToString().Replace("&nbsp;", " ").Replace("<br/>", "\r\n");
                tbAssessment.Text    = row[15].ToString().Trim();

                //if (row[14].ToString().Trim() == "CP")
                //{
                //    tbAssessmentRemarks.Text = row[16].ToString().Trim();
                //    colAssessRemarks.Visible = true;
                //}
                //else
                //{
                //    tbAssessmentRemarks.Text = "N/A";
                //    colAssessRemarks.Visible = false;
                //}

                if (string.IsNullOrEmpty(row[16].ToString().Trim()))
                {
                    tbAssessmentRemarks.Text = "N/A";
                }
                else
                {
                    tbAssessmentRemarks.Text = row[16].ToString().Trim();
                }

                if (row.IsNull(20))
                {
                    tbIsExistingJig.Text = "N/A";
                }
                else
                {
                    if (Convert.ToBoolean(row[20]) == true)
                    {
                        tbIsExistingJig.Text = "Yes";
                    }
                    else
                    {
                        tbIsExistingJig.Text = "No";
                    }
                }

                if (Convert.ToBoolean(row[18]) == true)
                {
                    rowHold.Visible = true;

                    remarksHold = "This request is set as hold. See below details:";

                    remarksHold += "<br />" + "<br />" + row[17].ToString().Replace("&nbsp;", " ").Replace("<br/>", "\r\n");

                    lblHoldRemarks.Text = remarksHold;
                }
                else
                {
                    rowHold.Visible = false;
                }
            }

            SQLDSGetAttachment.ConnectionString = ClsConfig.JobRequestConnectionString;

            if (incharge == "01" || incharge == "02" || incharge == "03")
            {
                rdoInCharge.SelectedValue = "07";
            }
            else if (incharge == "04" || incharge == "05" || incharge == "06")
            {
                rdoInCharge.SelectedValue = "08";
            }
            else
            {
                rdoInCharge.SelectedValue = incharge;
            }

            GetRequestorDetails(userempid);

            GetTypeOfRequest(Session["RCode"].ToString().Trim());

            if (rdoInCharge.SelectedValue == "04" || rdoInCharge.SelectedValue == "05" || rdoInCharge.SelectedValue == "08")
            {
                rowJigs.Visible       = true;
                rowFacilities.Visible = false;
            }
            else
            {
                rowJigs.Visible       = false;
                rowFacilities.Visible = true;
            }
        }
Ejemplo n.º 28
0
        public ActionResult Details(short id = 0)
        {
            ApprovedUPViewModel viewModel = new ApprovedUPViewModel();
            UP up = db.UPs.Find(id);

            if (up == null)
            {
                return(HttpNotFound());
            }

            List <UPREQUEST>         uprequestList   = new List <UPREQUEST>();
            List <EXBOND>            exbondList      = new List <EXBOND>();
            List <BACKTOBACKLC>      b2bList         = new List <BACKTOBACKLC>();
            List <BACKTOBACKPRODUCT> productList     = new List <BACKTOBACKPRODUCT>();
            List <RAWMATERIAL>       rawmaterialList = new List <RAWMATERIAL>();
            List <ATTACHMENT>        attachments     = new List <ATTACHMENT>();

            var uprequests = db.UPREQUESTLISTs.Where(eb => eb.UPID == id).ToList();

            for (int i = 0; i < uprequests.Count(); i++)
            {
                UPREQUEST uprequest = db.UPREQUESTs.Find(uprequests[i].UPREQUESTID);

                if (uprequest != null)
                {
                    for (int j = 0; j < uprequest.UPEXBONDLISTs.Count(); j++)
                    {
                        EXBOND exbond = db.EXBONDs.Find(uprequest.UPEXBONDLISTs[j].EXBONDID);
                        if (exbond != null)
                        {
                            for (int k = 0; k < exbond.EXBONDBACKTOBACKs.Count(); k++)
                            {
                                BACKTOBACKLC backtoback = db.BACKTOBACKLCs.Find(exbond.EXBONDBACKTOBACKs.ElementAt(k).BACKTOBACKID);
                                if (backtoback != null)
                                {
                                    for (int l = 0; l < backtoback.BACKTOBACKPRODUCTs.Count(); l++)
                                    {
                                        BACKTOBACKPRODUCT product = db.BACKTOBACKPRODUCTs.Find(backtoback.BACKTOBACKPRODUCTs[l].ID);
                                        if (product != null)
                                        {
                                            if (product.RAWMATERIALs.Count() > 0)
                                            {
                                                rawmaterialList = product.RAWMATERIALs.ToList();
                                            }
                                            productList.Add(product);
                                        }
                                    }
                                    b2bList.Add(backtoback);
                                }
                            }
                            exbondList.Add(exbond);
                        }
                    }
                    if (uprequest.ATTACHMENTs.Count() > 0)
                    {
                        attachments = uprequest.ATTACHMENTs.ToList();
                    }
                    uprequestList.Add(uprequest);
                }
            }

            viewModel.UP                 = up;
            viewModel.UPREQUESTs         = uprequestList;
            viewModel.BACKTOBACKLCs      = b2bList;
            viewModel.BACKTOBACKPRODUCTs = productList;
            viewModel.EXBONDs            = exbondList;
            viewModel.RAWMATERIALs       = rawmaterialList;
            viewModel.ATTACHMENTs        = attachments;
            return(View(viewModel));
        }
Ejemplo n.º 29
0
        public ActionResult CreateOREditUP(IList <UPREQUEST> requests, string UPNO, short ID = 0)
        {
            USERPERMISSION    loggedinUser = sessionAttributeRetreival.getStoredUserPermission();
            IList <UPREQUEST> requestList  = new List <UPREQUEST>();
            UP   up            = new UP();
            bool flag          = true;
            bool isanyselected = false;

            if (UPNO == null || UPNO.Equals(""))
            {
                return(RedirectToAction("Create", new { error = "Please Provide UP NO" }));
            }
            else
            {
                UP duplicateUp = db.UPs.SingleOrDefault(u => u.UPNO.Equals(UPNO));
                if (duplicateUp != null)
                {
                    return(RedirectToAction("Create", new { error = "UP No Already Exists" }));
                }
            }
            for (int i = 0; i < requests.Count(); i++)
            {
                int id = requests[i].ID;
                if (requests[i].IsSelected)
                {
                    isanyselected = true;
                    UPREQUEST request      = db.UPREQUESTs.Find(id);
                    int       productCount = request.UPEXBONDLISTs.Count();
                    if (productCount < 1)
                    {
                        flag = false;
                    }
                    else
                    {
                        requestList.Add(request);
                        up.BONDERID = request.BONDERID;
                    }
                }
            }
            if (!isanyselected && ID <= 0)
            {
                return(RedirectToAction("Create", new { error = "Please select at least one exbond" }));
            }
            if (!flag && ID <= 0)
            {
                return(RedirectToAction("Create", new { error = "Sorry! please check all selected Requests has at least one exbond" }));
            }
            else
            {
                short lastInserted = 0;

                if (ID <= 0)//add new UP
                {
                    DateTime thisDay = DateTime.Today;
                    up.CREATEDDATE = thisDay;
                    if (loggedinUser != null)
                    {
                        up.CREATEDBY = loggedinUser.APPUSER.USERNAME;
                    }
                    up.UPNO = UPNO;
                    db.UPs.Add(up);
                    db.SaveChanges();
                    lastInserted = db.UPs.Max(item => item.ID);
                }
                else//Edit existing UP
                {
                    if (loggedinUser != null)
                    {
                        up.MODIFIEDBY = loggedinUser.APPUSER.USERNAME;
                    }
                    up = db.UPs.Find(ID);
                    UP newUp = new UP();
                    newUp.ID           = ID;
                    newUp.BONDERID     = up.BONDERID;
                    newUp.UPNO         = up.UPNO;
                    newUp.MODIFIEDDATE = DateTime.Today;
                    newUp.CREATEDDATE  = up.CREATEDDATE;
                    newUp.CREATEDBY    = up.CREATEDBY;
                    using (var db2 = new OracleEntitiesConnStr())
                    {
                        db2.Entry(newUp).State = EntityState.Modified;
                        db2.SaveChanges();
                    }
                    lastInserted = ID;
                }
                for (int x = 0; x < requestList.Count(); x++)
                {
                    using (var db1 = new OracleEntitiesConnStr())//save value to relational table
                    {
                        UPREQUESTLIST uprequestList = new UPREQUESTLIST();
                        uprequestList.UPREQUESTID = requestList[x].ID;
                        uprequestList.UPID        = lastInserted;
                        db1.UPREQUESTLISTs.Add(uprequestList);
                        db1.SaveChanges();
                    }
                    using (var db2 = new OracleEntitiesConnStr()) //change status of up request as approved
                    {
                        UPREQUEST request = new UPREQUEST();      // db.UPREQUESTs.Find(requestList[x].ID);
                        request.ID               = requestList[x].ID;
                        request.BONDERID         = requestList[x].BONDERID;
                        request.STATUS           = 20; //approved
                        db2.Entry(request).State = EntityState.Modified;
                        db2.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 30
0
        protected void Approve(object sender, EventArgs e)
        {
            string link = string.Empty, body = string.Empty;

            var count = dbContext.tblAttachments.Where(x => x.jr_code == jrcode &&
                                                       x.typeofattachment.Trim() == "Admin" && x.IsCheckerReviewed == false && x.IsApproverReviewed == false).Count();

            if (count > 0)
            {
                Show("Some attachments are not yet reviewed. Must download and review the attachments first.");
            }
            else
            {
                var app = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

                if (app != null)
                {
                    app.IsHold = false;

                    app.AttachementStatus = "NOTED";

                    app.CreationDateTime = DateTime.Now;

                    dbContext.Entry(app).State = EntityState.Modified;

                    dbContext.SaveChanges();
                }

                var accept = dbContext.tblAttachments.Where(x => x.jr_code == jrcode &&
                                                            x.typeofattachment.Trim() == "Admin").FirstOrDefault();

                if (accept != null)
                {
                    accept.CheckedBy = approverfullname_fnamefirst;

                    accept.IsChecked = true;

                    accept.datecreated = DateTime.Now;

                    dbContext.Entry(accept).State = EntityState.Modified;

                    dbContext.SaveChanges();
                }

                link = Environment.NewLine + "http://" + HttpContext.Current.Request.Url.Authority + "/"
                       + ConfigurationManager.AppSettings["AttachmentApproverPage"];

                var asstr = (from data in dbContext.tblUsers
                             join approvers in dbContext.tblApprovers on data.EmpID equals approvers.EmpID
                             into UP
                             from approvers in UP.DefaultIfEmpty()
                             where approvers.OrderValue == 1
                             select new
                {
                    EmpID = data.EmpID,
                    EmailAdd = data.EmailAdd
                }
                             ).ToList();

                foreach (DataRow dr in ConvertToDataTable(asstr).Rows)
                {
                    body = "Dear Sir/Ma'am," + "<br /><br />" + "Good Day!";

                    body += "<br /><br />" + "I Have Prepared A Job Order Request Attachment/s For Your Checking And Approval.";

                    body += "<br /><br />" + "You may click the link below to redirect to main page. ";

                    body += "<br /><br />" + link + "?EmpID=" + dr["EmpID"].ToString().Trim() + "&RCode=" + Session["RCode"].ToString().Trim();

                    body += "<br /><br />" + "Thank You.";

                    body += "<br /><br />" + "Note: This is a system generated email. Please do not reply. Thank you";

                    var rx = new Regex(@"(?<=\w)\w");

                    var newString2 = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                    using (MailMessage mm = new MailMessage())
                    {
                        string sub = "Online Job Order Request: Requesting For Approval";

                        mm.Subject = sub.ToUpper();

                        mm.Body = body;

                        var newString = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                        mm.From = new MailAddress(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),

                                                  ConfigurationManager.AppSettings["MailSenderName"].ToString());

                        mm.To.Add(dr["EmailAdd"].ToString().Trim());

                        SmtpClient smtp = new SmtpClient();

                        smtp.Host = ConfigurationManager.AppSettings["MailServer"].ToString();

                        smtp.EnableSsl = true;

                        mm.IsBodyHtml = true;

                        NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),
                                                                              ConfigurationManager.AppSettings["MailSenderEmailPassword"].ToString());

                        smtp.Credentials = NetworkCred;

                        smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);

                        ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate,
                                                                                           X509Chain chain, SslPolicyErrors sslPolicyErrors)
                        { return(true); };
                        smtp.Send(mm);
                    }
                }

                //SendToRequestor();

                divSuccess.Visible = true;

                divApplication.Visible = false;
            }
        }