Пример #1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSubject.Text) && string.IsNullOrEmpty(txtContent.Text))
            {
                MessageBox.Show("Please input Subject and Content");
                return;
            }

            string fromEmail = UserUtil.ItUserName3();
            //string fromEmail = "*****@*****.**";
            string subject = txtSubject.Text;
            string content = txtContent.Text;

            foreach (DataGridViewRow row in dgvFailedList.Rows)
            {
                try
                {
                    string selected = row.Cells[3].FormattedValue.ToString();

                    string company = row.Cells[0].Value.ToString();
                    string staffid = row.Cells[1].Value.ToString();

                    string domain = company == "KDTHK" ? "kmhk.local" : "kmas.local";

                    if (selected == "True")
                    {
                        string to = AdUtil.GetEmailByUserId(staffid, domain);

                        try
                        {
                            //string hostname = staffid.StartsWith("hk") || staffid.StartsWith("HK") ? "HSP1EXHC.kmhk.local" : "ASP1EX1.kmas.local";
                            string     hostname = "HSP1EXHC.kmhk.local";
                            SmtpClient client   = new SmtpClient(hostname);
                            client.DeliveryMethod = SmtpDeliveryMethod.Network;

                            using (var message = new MailMessage(fromEmail, to)
                            {
                                Subject = subject,
                                Body = content
                            })
                            {
                                string path = staffid.StartsWith("hk") || staffid.StartsWith("HK") ? @"\\kdthk-dm1\project\IT System\IT Education\IT_Education.zip" : @"\\kmas-dcmain\ITuse\Education\IT_Education.zip";
                                message.Attachments.Add(new Attachment(path));
                                client.Send(message);
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message + ex.StackTrace);
                        }
                    }
                }
                catch (Exception ex)
                {
                    continue;
                }
            }

            MessageBox.Show("Mail has been sent.");
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string createdby = txtUser.Text.Trim();
            string created   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            string department = txtDepartment.Text.Trim();

            string key     = txtKey.Text.Trim();
            string remarks = txtRemarks.Text.Trim();

            string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User));
            string divHead  = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User));

            string adm1st = "Sammy Chow Chi To (周志滔)";
            string adm2nd = "Sammy Chow Chi To (周志滔)";

            string query = string.Format("insert into TB_ADM_FORM_KEY (ak_createdby, ak_created, ak_department, ak_key, ak_remarks, ak_sect, ak_div, ak_adm1st, ak_adm2nd)" +
                                         " values (N'{0}', '{1}', N'{2}', N'{3}', N'{4}', N'{5}', N'{6}', N'{7}', N'{8}')", createdby, created, department, key, remarks, sectHead, divHead, adm1st, adm2nd);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(sectHead, "kmhk.local"), "kmhk.local");

            string text = "Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
            string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";

            EformUtil.SendApprovalEmail("", GlobalService.User, from, to, body, "Approval Required - 複製鎖匙依賴");

            MessageBox.Show("Record has been saved.");

            DialogResult = DialogResult.OK;
        }
        private void lklForgot_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //PasswordResetForm form = new PasswordResetForm();
            //form.ShowDialog();
            string staffId = AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local");

            string password = GetOriginalPassword(staffId.Replace("hk", ""));

            string fromEmail = "*****@*****.**";
            string subject   = "Your Password has been restored.";
            string content   = "Your password has been restored. Please use the password below to access personal data (Salary Advice).\n\n" + password + "\n\nThis is system message. Please do not reply.";

            try
            {
                string     hostname = "Kdmail.km.local";
                SmtpClient client   = new SmtpClient(hostname);
                string     toEmail  = AdUtil.GetEmailByUserId(staffId, "kmhk.local");
                client.DeliveryMethod = SmtpDeliveryMethod.Network;

                using (var message = new MailMessage(fromEmail, toEmail)
                {
                    Subject = subject,
                    Body = content
                })
                {
                    client.Send(message);
                }

                MessageBox.Show("Your password has been restored. Please check your Email.");
            }
            catch
            {
                MessageBox.Show("Your password cannot be reset. Please contact system administrator.");
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {//
            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername("Lai Sui Mei(黎少薇,Olive)", "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername("Hara Masatoshi(原雅俊)", "kmhk.local"), "kmhk.local");

            EformUtil.SendR3ApprovalEmail("IT-R-0000031", "New User R/3 ID Request,Authority same as  Katty Zhang ID: H160004", "", "", from, to, "Lai Sui Mei(黎少薇,Olive)");
        }
Пример #5
0
        private void SaveData()
        {
            string applicant  = GlobalService.User;
            string category   = cbType.SelectedItem.ToString().Trim();
            string type       = cbR3Type.SelectedItem.ToString().Trim();
            string title      = "R3申請 - " + category + type;
            string r3id       = txtR3Id.Text.Trim();
            string request    = txtRequest.Text.Trim();
            string reason     = txtReason.Text.Trim();
            string start      = dtpStart.Value.ToString("yyyy/MM/dd");
            string attachment = txtAttachment.Text.Trim() != "" ? txtAttachment.Text.Trim() : "";
            string approver   = txtHead.Text.Trim();

            string cmApprover = GlobalService.User; //"Hara Masatoshi(原雅俊)";
            string itApprover = GlobalService.User; //"Chan Fai Lung(陳輝龍,Onyx)";

            string chaseno = GetLatestChaseno();

            string filePath = "";

            if (attachment != "")
            {
                string filename  = Path.GetFileName(attachment);
                string directory = @"\\kdthk-dm1\project\kdthk-dm\Forms\R3 Application\" + GlobalService.User + @"\";

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                File.Copy(attachment, directory + filename, true);

                filePath = directory + filename;
            }

            string query = string.Format("insert into TB_FORM_R3 (r_applicant, r_title, r_category, r_type, r_r3id, r_request, r_reason" +
                                         ", r_start, r_attachment, r_approver, r_cmapprover, r_itapprover, r_created, r_chaseno) values (N'{0}', N'{1}', N'{2}', '{3}', N'{4}', N'{5}', N'{6}', '{7}', N'{8}', N'{9}', N'{10}', N'{11}', '{12}', '{13}')",
                                         applicant, title, category, type, r3id, request, reason, start, filePath, approver, cmApprover, itApprover, DateTime.Today.ToString("yyyy/MM/dd"), chaseno);

            DataService.GetInstance().ExecuteNonQuery(query);

            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(approver, "kmhk.local"), "kmhk.local");

            string text = "IT Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
            string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";

            EformUtil.SendApprovalEmail(chaseno, GlobalService.User, from, to, body, title);

            DialogResult = DialogResult.OK;
        }
Пример #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string createdby = txtUser.Text.Trim();
            string created = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            string dept = txtDepartment.Text.Trim();

            string company = txtCompany.Text.Trim();
            string license = txtLicense.Text.Trim();

            string dt = dtpDate.Value.ToString("yyyy/MM/dd");

            string timeFrom = txtFrom.Text.Trim();
            string timeTo = txtTo.Text.Trim();

            string others = txtOthers.Text.Trim();

            if (string.IsNullOrEmpty(license))
            {
                MessageBox.Show("請先輸入車牌號");
                return;
            }

            string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User));
            string divHead = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User));

            string adm1st = "Sammy Chow Chi To (周志滔)";
            string adm2nd = "Sammy Chow Chi To (周志滔)";

            string query = string.Format("insert into TB_ADM_FORM_PARK (ap_createdby, ap_created, ap_department, ap_company, ap_license, ap_date, ap_others, ap_sect, ap_div, ap_adm1st, ap_adm2nd, ap_from, ap_to)" +
                " values (N'{0}', '{1}', N'{2}', N'{3}', '{4}', '{5}', N'{6}', N'{7}', N'{8}', N'{9}', N'{10}', '{11}', '{12}')", createdby, created, dept, company, license, dt, others, sectHead, divHead, adm1st, adm2nd, timeFrom, timeTo);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(sectHead, "kmhk.local"), "kmhk.local");

            string text = "Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
            string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";
            EformUtil.SendApprovalEmail("", GlobalService.User, from, to, body, "Approval Required - 訪客車位申請");

            MessageBox.Show("Record has been saved.");

            DialogResult = DialogResult.OK;
        }
Пример #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string createdby = txtUser.Text.Trim();
            string created   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            string department = txtDepartment.Text.Trim();

            string china    = ckbChina.Checked ? "Yes" : "No";
            string taiwan   = ckbTaiwan.Checked ? "Yes" : "No";
            string india    = ckbIndia.Checked ? "Yes" : "No";
            string czech    = ckbCzech.Checked ? "Yes" : "No";
            string usa      = ckbUsa.Checked ? "Yes" : "No";
            string vietnam1 = ckbVietnam1.Checked ? "Yes" : "No";
            string vietnam2 = ckbVietnam2.Checked ? "Yes" : "No";
            string others   = txtOthers.Text.Trim();

            string date   = dtpDate.Value.ToString("yyyy/MM/dd");
            string reason = txtReason.Text.Trim();

            string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User));
            string divHead  = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User));

            string adm1st = "Sammy Chow Chi To (周志滔)";
            string adm2nd = "Sammy Chow Chi To (周志滔)";

            string query = string.Format("insert into TB_ADM_FORM_VISA (av_createdby, av_created, av_department, av_china, av_taiwan, av_india, av_czech" +
                                         ", av_usa, av_vietnam1, av_vietnam2, av_others, av_indate, av_reason, av_sect, av_div, av_adm1st, av_adm2nd) values (N'{0}', '{1}', N'{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', N'{10}', '{11}', N'{12}', N'{13}', N'{14}', N'{15}', N'{16}')",
                                         createdby, created, department, china, taiwan, india, czech, usa, vietnam1, vietnam2, others, date, reason, sectHead, divHead, adm1st, adm2nd);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(sectHead, "kmhk.local"), "kmhk.local");

            string text = "Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
            string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";

            EformUtil.SendApprovalEmail("", GlobalService.User, from, to, body, "Approval Required - 簽証申請");

            MessageBox.Show("Record has been saved.");

            DialogResult = DialogResult.OK;
        }
Пример #8
0
        private void changeApproverToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserHeadForm form = new UserHeadForm("user");

            if (form.ShowDialog() == DialogResult.OK)
            {
                switch (MessageBox.Show("Are you sure to change the approver to " + GlobalService.SelectedUserHead + "?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                case DialogResult.Yes:
                    foreach (DataGridViewRow row in dgvForm.SelectedRows)
                    {
                        string status = row.Cells[0].Value.ToString().Trim();
                        string refno  = row.Cells[6].Value.ToString().Trim();

                        string query = status == "係責承認中" ? string.Format("update TB_ACC_OUTSTANDING set o_sect = N'{0}' where o_invoice = '{1}'", GlobalService.SelectedUserHead, refno)
                                : status == "科責承認中" ? string.Format("update TB_ACC_OUTSTANDING set o_div = N'{0}' where o_invoice = '{1}'", GlobalService.SelectedUserHead, refno)
                                : status == "部責承認中" ? string.Format("update TB_ACC_OUTSTANDING set o_dept = N'{0}' where o_invoice = '{1}'", GlobalService.SelectedUserHead, refno) : "";

                        if (query != "")
                        {
                            DataServiceCM.GetInstance().ExecuteNonQuery(query);

                            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

                            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.SelectedUserHead, "kmhk.local"), "kmhk.local");

                            string text = "Outstanding Slip Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
                            string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";
                            EformUtil.SendApprovalEmail(refno, GlobalService.User, from, to, body, "Outstanding Slip");
                        }
                    }

                    MessageBox.Show("Record has been saved.");

                    LoadData();
                    break;

                case DialogResult.No:
                    break;
                }
            }
        }
Пример #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User));
            string divHead  = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User));
            //string deptHead = "Ho Kin Hang(何健恒,Ken)";// UserUtil.GetDepartmentHead(UserUtil.GetDept(GlobalService.User));

            string adm1st = "Sammy Chow Chi To (周志滔)";
            string adm2nd = "Sammy Chow Chi To (周志滔)";
            //string adm3rd = "Ho Kin Hang(何健恒,Ken)";//"Sammy Chow Chi To (周志滔)";

            string createdby = txtUser.Text.Trim();
            string created   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            string department = txtDepartment.Text.Trim();

            string fee = txtFee.Text.Trim();

            string deptShared1 = txtDeptShared1.Text.Trim();
            string deptShared2 = txtDeptShared2.Text.Trim();

            string content = rtbContent.Text.Trim();

            string query = string.Format("insert into TB_ADM_FORM_REPAIR (ar_created, ar_createdby, ar_department, ar_fee, ar_deptshared1, ar_deptshared2" +
                                         ", ar_content, ar_sect, ar_div, ar_adm1st, ar_adm2nd) values ('{0}', N'{1}', N'{2}', '{3}', N'{4}', N'{5}', N'{6}', N'{7}', N'{8}', N'{9}', N'{10}')", created, createdby, department, fee,
                                         deptShared1, deptShared2, content, sectHead, divHead, adm1st, adm2nd);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(sectHead, "kmhk.local"), "kmhk.local");

            string text = "Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
            string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";

            EformUtil.SendApprovalEmail("", GlobalService.User, from, to, body, "Approval Required - 業務/修理依賴");

            MessageBox.Show("Record has been saved.");

            DialogResult = DialogResult.OK;
        }
Пример #10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            dgvItems.EndEdit();

            string createdby  = txtUser.Text.Trim();
            string created    = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
            string department = txtDepartment.Text.Trim();

            string s1qty = dgvItems.Rows[0].Cells[1].Value.ToString();
            double s1amt = Convert.ToDouble(dgvItems.Rows[0].Cells[2].Value);

            string s2qty = dgvItems.Rows[1].Cells[1].Value.ToString();
            double s2amt = Convert.ToDouble(dgvItems.Rows[1].Cells[2].Value);

            string s3qty = dgvItems.Rows[2].Cells[1].Value.ToString();
            double s3amt = Convert.ToDouble(dgvItems.Rows[2].Cells[2].Value);

            string s4qty = dgvItems.Rows[3].Cells[1].Value.ToString();
            double s4amt = Convert.ToDouble(dgvItems.Rows[3].Cells[2].Value);

            string s5qty = dgvItems.Rows[4].Cells[1].Value.ToString();
            double s5amt = Convert.ToDouble(dgvItems.Rows[4].Cells[2].Value);

            string s6qty = dgvItems.Rows[5].Cells[1].Value.ToString();
            double s6amt = Convert.ToDouble(dgvItems.Rows[5].Cells[2].Value);

            string s7qty = dgvItems.Rows[6].Cells[1].Value.ToString();
            double s7amt = Convert.ToDouble(dgvItems.Rows[6].Cells[2].Value);

            string s8qty = dgvItems.Rows[7].Cells[1].Value.ToString();
            double s8amt = Convert.ToDouble(dgvItems.Rows[7].Cells[2].Value);

            string s9qty = dgvItems.Rows[8].Cells[1].Value.ToString();
            double s9amt = Convert.ToDouble(dgvItems.Rows[8].Cells[2].Value);

            string s10qty = dgvItems.Rows[9].Cells[1].Value.ToString();
            double s10amt = Convert.ToDouble(dgvItems.Rows[9].Cells[2].Value);

            double total    = s1amt + s2amt + s3amt + s4amt + s5amt + s6amt + s7amt + s8amt + s9amt + s10amt;
            string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User));
            string divHead  = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User));

            string adm1st = "Sammy Chow Chi To (周志滔)";
            string adm2nd = "Sammy Chow Chi To (周志滔)";

            string query = string.Format("insert into TB_ADM_FORM_STAMP (as_createdby, as_created, as_department, as_total, as_s1qty, as_s1amt, as_s2qty, as_s2amt" +
                                         ", as_s3qty, as_s3amt, as_s4qty, as_s4amt, as_s5qty, as_s5amt, as_s6qty, as_s6amt, as_s7qty, as_s7amt, as_s8qty, as_s8amt, as_s9qty, as_s9amt, as_s10qty, as_s10amt" +
                                         ", as_sect, as_div, as_adm1st, as_adm2nd) values (N'{0}', '{1}', N'{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}', '{23}', N'{24}', N'{25}', N'{26}', N'{27}')",
                                         createdby, created, department, total, s1qty, s1amt, s2qty, s2amt, s3qty, s3amt, s4qty, s4amt, s5qty, s5amt, s6qty, s6amt, s7qty, s7amt, s8qty, s8amt, s9qty, s9amt, s10qty, s10amt, sectHead, divHead, adm1st, adm2nd);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(sectHead, "kmhk.local"), "kmhk.local");

            string text = "Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
            string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";

            EformUtil.SendApprovalEmail("", GlobalService.User, from, to, body, "Approval Required - 購買郵票依賴");

            MessageBox.Show("Record has been saved.");

            DialogResult = DialogResult.OK;
        }
Пример #11
0
        private void SaveData()
        {
            if (string.IsNullOrEmpty(txtTitle.Text))
            {
                MessageBox.Show("請輸入申請項目主題");
                return;
            }

            rtbContent.SaveFile("temp.rtf");
            FileStream stream = new FileStream("temp.rtf", FileMode.Open, FileAccess.Read);
            int        size   = Convert.ToInt32(stream.Length);

            Byte[] rtf = new Byte[size];
            stream.Read(rtf, 0, size);

            string user = txtUser.Text.Trim();

            string category = ckbSupport.Checked ? "IT技術支援" : ckbComment.Checked ? "IT意見箱" : "IT綜合申請";

            string start = dtpStart.Value.ToString("yyyy/MM/dd");

            string end = dtpEnd.Value.ToString("yyyy/MM/dd");

            string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            string head = txtHead.Text.Trim();

            string chaseno = GetLatestChaseno();

            string title = txtTitle.Text.Trim();

            if (title.Contains("'"))
            {
                title = title.Replace("'", "''");
            }

            if (category != "IT技術支援" && category != "IT意見箱")
            {
                string query = string.Format("insert into TB_FORM (f_chaseno, f_type, f_content, f_start, f_end, f_created, f_createdby, f_status, f_applicant, f_approver, f_title)" +
                                             " values ('{0}', N'{1}', @Content, '{2}', '{3}', '{4}', N'{5}', N'{6}', N'{7}', N'{8}', N'{9}')", chaseno, category, start, end, now, GlobalService.User, "上司承認中", user, head, title);

                SqlCommand cmd = new SqlCommand(query, DataService.GetInstance().Connection);

                SqlParameter param = new SqlParameter("@Content", SqlDbType.Image, rtf.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rtf);
                cmd.Parameters.Add(param);

                cmd.ExecuteNonQuery();

                //Send Email
                string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

                string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(head, "kmhk.local"), "kmhk.local");

                string text = "IT Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
                string body = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";
                EformUtil.SendApprovalEmail(chaseno, GlobalService.User, from, to, body, txtTitle.Text.Trim());
            }
            else
            {
                string query = string.Format("insert into TB_FORM (f_chaseno, f_type, f_content, f_start, f_end, f_createdby, f_created, f_status, f_applicant, f_approver, f_title)" +
                                             " values ('{0}', N'{1}', @Content, '{2}', '{3}', N'{4}', N'{5}', N'{6}', N'{7}', N'{8}', N'{9}')", chaseno, category, start, end, GlobalService.User, now, "申請已發送", user, "---", title);

                SqlCommand cmd = new SqlCommand(query, DataService.GetInstance().Connection);

                SqlParameter param = new SqlParameter("@Content", SqlDbType.Image, rtf.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rtf);
                cmd.Parameters.Add(param);

                cmd.ExecuteNonQuery();

                string email = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

                EformUtil.SendReceivedEmail(chaseno, email, txtTitle.Text.Trim());

                EformUtil.SendNotificationEmail(chaseno, category, GlobalService.User, email, txtTitle.Text.Trim(), rtbContent.Rtf, rtbContent.Width, rtbContent.Height, rtbContent);
            }

            DialogResult = DialogResult.OK;
        }
Пример #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string createdby = txtUser.Text.Trim();
            string created   = DateTime.Today.ToString("yyyy/MM/dd");

            string department = txtDepartment.Text.Trim();

            string remarks = txtRemarks.Text.Trim();

            string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User));
            string divHead  = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User));

            string adm1st = "Sammy Chow Chi To (周志滔)";
            string adm2nd = "Sammy Chow Chi To (周志滔)";

            if (remarks.Contains("'"))
            {
                remarks = remarks.Replace("'", "''");
            }

            string query = string.Format("insert into TB_ADM_FORM_PURCHASE (ap_created, ap_createdby, ap_department, ap_remarks, ap_sect, ap_div, ap_adm1st, ap_adm2nd)" +
                                         " values ('{0}', N'{1}', N'{2}', N'{3}', N'{4}', N'{5}', N'{6}', N'{7}')", created, createdby, department, remarks, sectHead, divHead, adm1st, adm2nd);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            string text = "select top 1 ap_id from TB_ADM_FORM_PURCHASE order by ap_id desc";
            int    id   = (int)DataServiceCM.GetInstance().ExecuteScalar(text);

            foreach (DataGridViewRow row in dgvItems.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                string item   = row.Cells[0].Value.ToString().Trim();
                string qty    = row.Cells[1].Value.ToString().Trim();
                string amount = row.Cells[2].Value.ToString().Trim();

                if (item.Contains("'"))
                {
                    item = item.Replace("'", "''");
                }

                string detailText = string.Format("insert into TB_ADM_FORM_PURCHASE_DETAIL (apd_ap_id, apd_item, apd_qty, apd_amount)" +
                                                  " values ('{0}', N'{1}', '{2}', '{3}')", id, item, qty, amount);

                DataServiceCM.GetInstance().ExecuteNonQuery(detailText);
            }

            string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"), "kmhk.local");

            string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(sectHead, "kmhk.local"), "kmhk.local");

            string emailText = "Application Approval required. Please click <a href=\"\\\\kdthk-dm1\\project\\it system\\MyCloud Beta\\KDTHK-DM-SP.application\">HERE</a> to approval process.";
            string body      = "<p><span style=\"font-family: Calibri;\">" + emailText + "</span></p>";

            EformUtil.SendApprovalEmail("", GlobalService.User, from, to, body, "Approval Required - 月度購買依賴");

            MessageBox.Show("Record has been saved.");

            DialogResult = DialogResult.OK;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            List <FaApplicationList> list = new List <FaApplicationList>();

            foreach (DataGridViewRow row in dgvMain.Rows)
            {
                string isChecked = row.Cells[15].FormattedValue.ToString();

                if (isChecked != "True")
                {
                    continue;
                }

                string chaseno    = row.Cells[0].Value.ToString().Trim();
                string vendor     = row.Cells[1].Value.ToString().Trim();
                string vendorname = row.Cells[2].Value.ToString().Trim();
                string partno     = row.Cells[3].Value.ToString().Trim();
                string itemtext   = row.Cells[11].Value.ToString().Trim();
                string ringi      = row.Cells[13].Value.ToString().Trim();
                string mouldJig   = row.Cells[14].Value.ToString().Trim();

                list.Add(new FaApplicationList {
                    Chaseno = chaseno, Itemcode = partno, Itemtext = itemtext, Ringi = ringi, Vendor = vendor + " " + vendorname, AppType = mouldJig
                });
            }

            if (list.Count > 0)
            {
                switch (MessageBox.Show("Are you sure to apply " + list.Count + " item for Fixed Asset?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                case DialogResult.Yes:
                    DataTable pdfTable = new DataTable();
                    string[]  headers  = { "ChaseNo", "Item Text", "Item Code", "Ringi", "Vendor" };
                    foreach (string header in headers)
                    {
                        pdfTable.Columns.Add(header);
                    }

                    string pdfFile = DataUtil.GetLatestPdfId();

                    string today = DateTime.Today.ToString("yyyy/MM/dd");

                    int mouldCount = 0;
                    int jigCount   = 0;

                    foreach (FaApplicationList item in list)
                    {
                        string query = string.Format("update tb_betamould set tm_st_code = 'A', tm_ringi_code = '{0}', tm_pdfid = '{1}' where tm_chaseno = '{2}'", item.Ringi, pdfFile, item.Chaseno);
                        DataService.GetInstance().ExecuteNonQuery(query);

                        pdfTable.Rows.Add(item.Chaseno, item.Itemtext, item.Itemcode, item.Ringi, item.Vendor);

                        string mpa      = DataUtil.GetMpa(item.Chaseno) == "True" ? "Yes" : "No";
                        string vendor   = DataUtil.GetVendor(item.Chaseno);
                        string path     = @"\\kdthk-dm1\moss$\cm\FixedAssets\" + pdfFile + ".pdf";
                        string model    = DataUtil.GetModel(item.Chaseno);
                        string currency = DataUtil.GetCurrency(item.Chaseno);
                        string amount   = DataUtil.GetAmount(item.Chaseno);

                        string approvalText = string.Format("insert into TB_FA_APPROVAL (f_request, f_applicant, f_type, f_chaseno, f_pdfid, f_status, f_desc, f_mpa, f_vendor, f_attachment" +
                                                            ", f_mould, f_ringi, f_model, f_currency, f_amount, f_assetdesc, f_ipo1st, f_ipo2nd, f_partno, f_apptype) values ('{0}', N'{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', N'{16}', N'{17}', '{18}', '{19}')"
                                                            , today, GlobalService.Owner, "Acquisition", item.Chaseno, pdfFile, "IPO 1st Approval", item.Itemtext, mpa, vendor, path, item.Chaseno, item.Ringi, model, currency, amount
                                                            , item.Vendor, GlobalService.IPO1st, GlobalService.IPO2nd, item.Itemcode, item.AppType);

                        DataServiceNew.GetInstance().ExecuteNonQuery(approvalText);

                        if (item.AppType == "Mould")
                        {
                            mouldCount += 1;
                        }
                        if (item.AppType == "Jigs")
                        {
                            jigCount += 1;
                        }
                    }

                    pdfTable.DefaultView.Sort = "ChaseNo ASC";

                    PdfUtil.ApplyFixedAssetPdf(pdfTable, pdfFile, mouldCount, jigCount);

                    string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.Owner, "kmhk.local"), "kmhk.local");
                    string to   = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.IPO1st, "kmhk.local"), "kmhk.local");

                    EmailUtil.SendEmail(from, to, "SpApp_Fixed Asset Application Approval Required");

                    DialogResult = DialogResult.OK;
                    break;

                case DialogResult.No:
                    break;
                }
            }
        }
Пример #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string title      = cbCategory.Text + " " + cbR3Category.Text;
            string startdate  = dtpStart.Value.ToString("yyyy/MM/dd");
            string comment    = txtComment.Text.Trim();
            string attachment = txtAttachment.Text.Trim();
            string category   = cbCategory.Text.Trim();
            string r3Category = cbR3Category.Text.Trim();

            string status = cbStatus.Text == "Completed" ? "經管承認中" : "IT處理中";

            string applicant = DataUtil.GetApplicant(GlobalService.ChaseNo);
            string head      = DataUtil.GetHead(applicant);

            string chaseno = DataUtil.GetR3Chaseno();

            string cmApprover = txtCmApprover.Text.Trim();
            //string itApprover = "Chan Fai Lung(陳輝龍,Onyx)";
            string itApprover = UserUtil.ItUserName2();

            if (cbStatus.Text == "Cancel")
            {
                string query = string.Format("delete from TB_FORM where f_chaseno = '{0}'", GlobalService.ChaseNo);
                DataService.GetInstance().ExecuteNonQuery(query);
            }
            else
            {
                string filePath = "";

                if (attachment != "")
                {
                    string filename  = Path.GetFileName(attachment);
                    string directory = @"\\kdthk-dm1\project\kdthk-dm\Forms\R3 Application\IT Attachments\";

                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }

                    File.Copy(attachment, directory + filename, true);

                    filePath = directory + filename;
                }

                string query = string.Format("insert into TB_FORM_R3 (r_chaseno, r_status, r_applicant, r_created, r_title, r_category, r_type, r_content, r_start" +
                                             ", r_approver, r_approval, r_cmapprover, r_cmapproval, r_itapprover, r_itapproval, r_itattachment, r_itcomment, r_refno) values ('{0}', N'{1}', N'{2}'" +
                                             ", '{3}', N'{4}', N'{5}', '{6}', N'{7}', '{8}', N'{9}', '{10}', N'{11}', '{12}', N'{13}', N'{14}', N'{15}', N'{16}', '{17}')", chaseno, status, applicant, DateTime.Today.ToString("yyyy/MM/dd"),
                                             title, category, r3Category, "", startdate, head, "Yes", cmApprover, "No", itApprover, "Yes", filePath, comment, GlobalService.ChaseNo);

                DataService.GetInstance().ExecuteNonQuery(query);

                string from = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(GlobalService.User));

                string to = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(cmApprover));

                EformUtil.SendR3ApprovalEmail(title, comment, filePath, "", from, to, GlobalService.User);
            }

            if (SavedEvent != null)
            {
                SavedEvent(this, new EventArgs());
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            dgvApproval.EndEdit();

            foreach (DataGridViewRow row in dgvApproval.Rows)
            {
                string approval = row.Cells[0].Value.ToString().Trim();

                if (approval == "---")
                {
                    continue;
                }

                string pdfid = row.Cells[3].Value.ToString().Trim();

                string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

                string query = "";

                string applicant = row.Cells[2].Value.ToString().Trim();

                string email = AdUtil.GetEmailByUserId(AdUtil.GetUserIdByUsername(applicant, "kmhk.local"), "kmhk.local");

                if (GlobalService.Owner == GlobalService.IPO1st)
                {
                    if (approval == "Approve")
                    {
                        query = string.Format("update TB_FA_APPROVAL set f_status = '{0}', f_ipo1stapp = '{1}', f_ipo1stdate = '{2}'" +
                                              " where f_pdfid = '{3}'", "IPO 2nd Approval", "Approve", now, pdfid);

                        EmailUtil.SendEmail(email, "*****@*****.**", "SpApp_Fixed Asset Application Approval Required");
                    }
                    else
                    {
                        query = string.Format("delete from TB_FA_APPROVAL where f_pdfid = '{0}'", pdfid);

                        RejectStatus(pdfid);
                    }
                }
                else
                {
                    if (approval == "Approve")
                    {
                        query = string.Format("update TB_FA_APPROVAL set f_status = '{0}', f_ipo2ndapp = '{1}', f_ipo2nddate = '{2}', f_ringi1st = N'{3}', f_cm1st = N'{4}', f_cm2nd = N'{5}', f_cm3rd = N'{6}'" +
                                              " where f_pdfid = '{7}'", "Ringi Approval", "Approve", now, "Lai King Ho(黎景豪,Ken)", "Lee Suk Ha(李淑霞,Zoe)", "Li Yuen Yan(李婉茵,Sharon)", "Leung Wai Yip(梁偉業,Philip)", pdfid);

                        try
                        {
                            EmailUtil.NotificationEmail(email, "*****@*****.**", "Fixed Asset Application Approval Required");
                        }
                        catch
                        {
                            Debug.WriteLine("aaa");
                        }
                    }
                    else
                    {
                        query = string.Format("delete from TB_FA_APPROVAL where f_pdfid = '{0}'", pdfid);

                        RejectStatus(pdfid);
                    }
                }

                DataServiceNew.GetInstance().ExecuteNonQuery(query);
            }

            LoadData();
        }