private void btnApprove_Click(object sender, EventArgs e)
        {
            string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            string text = _status == "科責承認中" ? string.Format("update TB_ACC_OUTSTANDING set o_divapproval = 'Yes', o_divapprovaldate = '{0}', o_status = N'會計處理中' where o_invoice = '{1}'", now, _invoice)
                : _status == "會計處理中" ? string.Format("update TB_ACC_OUTSTANDING set o_staffapproval = 'Yes', o_staffapprovaldate = '{0}', o_status = N'會計承認中' where o_invoice = '{1}'", now, _invoice)
                : string.Format("update TB_ACC_OUTSTANDING set o_accapproval = 'Yes', o_accapprovaldate = '{0}', o_status = N'申請處理完成' where o_invoice = '{1}'", now, _invoice);

            DataServiceCM.GetInstance().ExecuteNonQuery(text);

            string applicant = AccUtil.GetApplicant(_invoice);
            string div       = AccUtil.GetDivisionApprover(_invoice);
            string staff     = AccUtil.GetAccStaff(_invoice);
            string acc       = AccUtil.GetAccApprover(_invoice);

            if (_status == "科責承認中")
            {
                EformUtil.SendApprovalEmail(_invoice, applicant, AdUtil.GetEmailByUsername(applicant, "kmhk.local"), AdUtil.GetEmailByUsername(staff, "kmhk.local"), "", "Outstanding Slip - " + _invoice);
            }

            if (_status == "會計處理中")
            {
                EformUtil.SendApprovalEmail(_invoice, applicant, AdUtil.GetEmailByUsername(applicant, "kmhk.local"), AdUtil.GetEmailByUsername(acc, "kmhk.local"), "", "Outstanding Slip - " + _invoice);
            }

            if (_status == "會計承認中")
            {
                EformUtil.SendFinishedEmail(_invoice, acc, AdUtil.GetEmailByUsername(acc, "kmhk.local"), AdUtil.GetEmailByUsername(applicant, "kmhk.local"), "Outstanding Slip Application Finished - " + _invoice, "You Outstanding Slip Application has been finished.");
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
        private void btnReject_Click(object sender, EventArgs e)
        {
            string query = string.Format("update TB_CM_DEBIT set d_status = N'拒絕承認' where d_docno = '{0}'", _docno);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            string sect      = "";
            string div       = "";
            string dept      = "";
            string createdby = "";

            string text = string.Format("select d_sect, d_div, d_dept, d_createdby from TB_CM_DEBIT where d_docno = '{0}'", _docno);

            using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(text))
            {
                while (reader.Read())
                {
                    sect      = reader.GetString(0).Trim();
                    div       = reader.GetString(1).Trim();
                    dept      = reader.GetString(2).Trim();
                    createdby = reader.GetString(3).Trim();
                }
            }

            string subject = "Debit/Credit Note Application has been Rejected";

            string content = "Dear Sir/Madam,\n\nYour Debit/Credit Note Application has been Rejected. Please go to MyCloud to revise or apply a new application.\n\nThis is system message, please do not reply.";

            EformUtil.SendRejectEmail(_docno, GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(createdby, "kmhk.local"), subject, content);//cc?
        }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtAttachment.Text == "")
            {
                switch (MessageBox.Show("No Attachment found. Continue?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                case DialogResult.Yes:
                    string query = string.Format("update TB_FORM_R3 set r_itattachment = N'{0}', r_status = N'經管承認中' where r_chaseno = '{1}'", "", _chaseno);
                    DataService.GetInstance().ExecuteNonQuery(query);

                    break;

                case DialogResult.No:
                    break;
                }
            }
            else
            {
                string query = string.Format("update TB_FORM_R3 set r_itattachment = N'{0}', r_status = N'經管承認中' where r_chaseno = '{1}'", txtAttachment.Text.Trim(), _chaseno);
                DataService.GetInstance().ExecuteNonQuery(query);
            }

            string from = AdUtil.GetEmailByUsername(txtApplicant.Text.Trim(), "kmhk.local");

            string to = AdUtil.GetEmailByUsername(_cmApprover, "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, from, to, body, "R3申請", txtApplicant.Text.Trim());
        }
Esempio n. 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            dgvAsset.EndEdit();

            if (!IsDataValid(dgvAsset))
            {
                MessageBox.Show("Invalid input found.");
                return;
            }

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

            string head = DataUtil.GetHead(applicant);

            string approval = DataUtil.IsItemApproved(GlobalService.ChaseNo) ? "Yes" : "No";

            string chaseno = DataUtil.GetAssetChaseNo();

            string status = approval == "Yes" ? "I.T.處理中" : "上司承認中";

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

                string category  = row.Cells[0].Value.ToString().Trim();
                string name      = row.Cells[1].Value.ToString().Trim();
                string start     = row.Cells[2].Value.ToString().Trim();
                string preReturn = row.Cells[3].Value.ToString().Trim();
                string inout     = row.Cells[4].Value.ToString().Trim();
                string assigned  = row.Cells[5].Value.ToString().Trim();

                string query = string.Format("insert into TB_FORM_LOANING (l_name, l_category, l_start, l_end, l_created, l_applicant, l_status, l_refno, l_approval, l_approver, l_chaseno, l_remarks, l_handledby)" +
                                             " values (N'{0}', N'{1}', '{2}', '{3}', '{4}', N'{5}', N'{6}', '{7}', '{8}', N'{9}', '{10}', '{11}', N'{12}')", name, category, start, preReturn, DateTime.Today.ToString("yyyy/MM/dd"), applicant, status, GlobalService.ChaseNo, approval, head, chaseno, inout, assigned);
                DataService.GetInstance().ExecuteNonQuery(query);

                //string text = string.Format("update TB_IT_ASSET set a_status = N'借用中', a_refno = '{0}' where a_name = '{1}'", GlobalService.ChaseNo, name);
                //DataServiceIT.GetInstance().ExecuteNonQuery(text);
            }

            if (approval == "No")
            {
                string from = AdUtil.GetEmailByUsername(applicant, "kmhk.local");
                string to   = AdUtil.GetEmailByUsername(head, "kmhk.local");

                EformUtil.SendApprovalEmail(GlobalService.ChaseNo, from, to, "Approval Required for 資產外借", "資產外借", applicant);
            }

            GlobalService.SavedForm = "asset";

            if (SavedEvent != null)
            {
                SavedEvent(this, new EventArgs());
            }
        }
Esempio n. 5
0
 public static string GetEmail(string user)
 {
     try
     {
         return(AdUtil.GetEmailByUsername(user, "kmhk.local"));
     }
     catch
     {
         return(AdUtil.GetEmailByUsername(user, "kmas.local"));
     }
 }
Esempio n. 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string category = cbCategory.SelectedItem.ToString();
            string item     = cbItem.SelectedItem.ToString();
            string date     = dtpComplete.Value.ToString("yyyy/MM/dd");
            string status   = cbStatus.SelectedItem.ToString();

            string assigned = cbAssign.SelectedItem.ToString().Trim();

            rtbRemarks.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 applicant = DataUtil.GetApplicant(GlobalService.ChaseNo);

            string head     = DataUtil.GetHead(applicant);
            string approval = DataUtil.IsItemApproved(GlobalService.ChaseNo) ? "Yes" : "No";

            string chaseno = DataUtil.GetDevelopChaseNo();

            string st = approval == "Yes" ? "I.T處理中" : "上司承認中";//status == "Completed" ? "申請處理完成" : status == "Processing" ? "I.T.處理中" : "取消";

            string query = string.Format("if not exists (select * from TB_FORM_DEVELOP where d_chaseno = '{0}') insert into TB_FORM_DEVELOP (d_chaseno, d_category, d_item, d_estimate, d_status, d_remarks, d_applicant, d_approver, d_approval, d_refno, d_created, d_handledby)" +
                                         " values ('{0}', '{1}', N'{2}', '{3}', N'{4}', @Remarks, N'{5}', N'{6}', '{7}', '{8}', '{9}', N'{10}') else update TB_FORM_DEVELOP set d_category = '{1}', d_item = N'{2}', d_estimate = '{3}', d_status = N'{4}', d_remarks = @Remarks where d_chaseno = '{0}'", chaseno, category, item, date, st, applicant, head, approval, GlobalService.ChaseNo, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), assigned);

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

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

            cmd.Parameters.Add(param);

            cmd.ExecuteNonQuery();

            GlobalService.SavedForm = "develop";

            if (approval == "No")
            {
                string from = AdUtil.GetEmailByUsername(applicant, "kmhk.local");
                string to   = AdUtil.GetEmailByUsername(head, "kmhk.local");

                string[] attachments = _attachList.Select(x => x.FilePath).ToArray();

                EformUtil.SendApprovalEmailWithAttachment(GlobalService.ChaseNo, from, to, "Approval Required for 工具開發/修改", "工具開發/修改", applicant, attachments);
                //EformUtil.SendApprovalEmail(GlobalService.ChaseNo, from, to, "Approval Required for 權限及軟件安裝", "權限及軟件安裝", applicant);
            }

            if (SavedEvent != null)
            {
                SavedEvent(this, new EventArgs());
            }
        }
Esempio n. 7
0
        public static void SendNotificationEmail(List <string> receiverList)
        {
            try
            {
                string fromEmail = AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local");

                string hostname = "Kdmail.km.local";

                string text = "Dear colleague,<br/><br/>You have received file from " + GlobalService.User + ". Please use the link below to read file.<br/><br/>" +
                              "<a href=\"\\\\172.16.13.231\\project\\KDTHK-DM\\littlesource\\LittleCloud.xlsm\">Installation Source (Excel 2007 or above)</a><br/><br/>" +
                              "<a href=\"\\\\172.16.13.231\\project\\KDTHK-DM\\littlesource\\LittleCloud.xls\">Installation Source (Excel 2003 only)</a><br/><br/>" +
                              "If you have any questions, please follow the instruction below.<br/><a href=\"\\\\172.16.13.231\\project\\KDTHK-DM\\littlesource\\Enable Macro.pdf\">Installation Guide</a><br/><br/>Regards";

                string content = "<p><span style=\"font-family: Calibri;\">" + text + "</span></p>";

                string subject = "File Received";

                foreach (string user in receiverList)
                {
                    string domain = UserUtil.IsCnMember(user) ? "kmcn.local"
                        : UserUtil.IsVnMember(user) ? "kdtvn.local"
                        : UserUtil.IsJpMember(user) ? "km.local" : "kmhk.local";

                    string toEmail = AdUtil.GetEmailByUsername(user, domain);

                    if (user == GlobalService.User)
                    {
                        continue;
                    }

                    if (!IsEmailSent(toEmail))
                    {
                        SmtpClient client = new SmtpClient(hostname);
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;

                        MailMessage mail = new MailMessage(fromEmail, toEmail);
                        mail.IsBodyHtml = true;
                        mail.Subject    = subject;
                        mail.Body       = content;
                        client.Send(mail);

                        string query = string.Format("insert into TB_EMAIL_RECORD (e_datetime, e_name, e_from, e_receiver, e_to) values ('{0}', N'{1}', N'{2}', N'{3}', N'{4}')", DateTime.Now.ToString("yyyy/MM/dd HH:mm"),
                                                     GlobalService.User, fromEmail, user, toEmail);
                        DataService.GetInstance().ExecuteNonQuery(query);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message + ex.StackTrace);
            }
        }
        private void btnReject_Click(object sender, EventArgs e)
        {
            string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            string text = _status == "科責承認中" ? string.Format("update TB_ACC_OUTSTANDING set o_divapproval = 'No', o_divapprovaldate = '{0}', o_status = N'科責已拒絕' where o_invoice = '{1}'", now, _invoice)
                : _status == "會計處理中" ? string.Format("update TB_ACC_OUTSTANDING set o_staffapproval = 'No', o_staffapprovaldate = '{0}', o_status = N'會計已拒絕' where o_invoice = '{1}'", now, _invoice)
                : string.Format("update TB_ACC_OUTSTANDING set o_accapproval = 'No', o_accapprovaldate = '{0}', o_status = N'會計已拒絕' where o_invoice = '{1}'", now, _invoice);

            DataServiceCM.GetInstance().ExecuteNonQuery(text);

            string applicant = AccUtil.GetApplicant(_invoice);

            EformUtil.SendRejectEmail(_invoice, GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(applicant, "kmhk.local"), "Outstanding Slip Rejected - " + _invoice, "Your Outstanding Slip has been rejected by " + GlobalService.User);

            DialogResult = DialogResult.OK;
        }
Esempio n. 9
0
        private void btnApprove_Click(object sender, EventArgs e)
        {
            string query = string.Format("select d_div, d_dept, d_mcstaff, d_mcreviewer, d_mcfinal, d_createdby, d_reason from TB_CM_DEBIT where d_docno = '{0}'", _docno);

            string target    = "";
            string applicant = "";
            string reason    = "";

            using (IDataReader reader = DataServiceCM.GetInstance().ExecuteReader(query))
            {
                while (reader.Read())
                {
                    target = _status == "係責承認中" ? reader.GetString(0).Trim()
                        : _status == "科責承認中" ? reader.GetString(1).Trim()
                        : _status == "部責承認中" ? reader.GetString(2).Trim()
                        : _status == "經管確認中" ? reader.GetString(3).Trim()
                        : _status == "經管檢查中" ? reader.GetString(4).Trim() : "";

                    applicant = reader.GetString(5).Trim();
                    reason    = reader.GetString(6).Trim();
                }
            }

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

            string text = _status == "係責承認中" ? string.Format("update TB_CM_DEBIT set d_status = N'科責承認中', d_sectapproval = 'Yes', d_sectdate = '{0}' where d_docno = '{1}'", now, _docno)
                        : _status == "科責承認中" ? string.Format("update TB_CM_DEBIT set d_status = N'部責承認中', d_divapproval = 'Yes', d_divdate = '{0}' where d_docno = '{1}'", now, _docno)
                        : _status == "部責承認中" ? string.Format("update TB_CM_DEBIT set d_status = N'經管確認中', d_deptapproval = 'Yes', d_deptdate = '{0}' where d_docno = '{1}'", now, _docno)
                        : _status == "經管檢查中" ? string.Format("update TB_CM_DEBIT set d_status = N'經管承認中', d_mcreviewerapproval = 'Yes', d_mcreviewerdate = '{0}' where d_docno = '{1}'", now, _docno)
                        : string.Format("update TB_CM_DEBIT set d_status = '申請處理完成', d_mcfinalapproval = 'Yes', d_mcfinaldate = '{0}' where d_docno = '{1}'", now, _docno);

            DataServiceCM.GetInstance().ExecuteNonQuery(text);

            string email     = AdUtil.GetEmailByUsername(target, "kmhk.local");
            string fromEmail = AdUtil.GetEmailByUsername(applicant, "kmhk.local");

            if (_status == "部責承認中")
            {
                EformUtil.SendApprovalEmail(_docno, applicant, fromEmail, email, reason, "Debit Note Application Approval Required: " + _docno);
            }
            else
            {
                EformUtil.SendDebitNotificationEmail(_docno, applicant, fromEmail, email, "Received a Debit/Credit Note Application Form\n\nPlease check in Management Console");
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            if (!rbtnApprove.Checked && !rbtnReject.Checked)
            {
                DialogResult = DialogResult.Cancel;
            }
            else if (rbtnApprove.Checked)
            {
                string query = _status == "上司承認中" ? string.Format("update TB_FORM_R3 set r_approval = 'Yes', r_status = N'申請已發送' where r_chaseno = '{0}'", _chaseno)
                    : string.Format("update TB_FORM_R3 set r_cmapproval = 'Yes', r_cmappdate = '{0}', r_status = N'申請處理完成' where r_chaseno = '{1}'", now, _chaseno);

                DataService.GetInstance().ExecuteNonQuery(query);

                if (_status == "上司承認中")
                {
                    string mail = AdUtil.GetEmailByUsername(_applicant, "kmhk.local");
                    EformUtil.SendR3NotificationEmail(_chaseno, "R3申請", _applicant, mail, _title, EformUtil.GetR3Id(_chaseno), EformUtil.GetR3Request(_chaseno), EformUtil.GetR3Reason(_chaseno));
                }
                else
                {
                    EformUtil.SendNotificationEmail(_chaseno, "R3申請", GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), "經管承認完了", "", 0, 0, null);
                }
                DialogResult = DialogResult.OK;
            }
            else
            {
                string query = _status == "上司承認中" ? string.Format("update TB_FORM_R3 set r_approval = 'Reject', r_status = N'上司已拒絕' where r_chaseno = '{0}'", _chaseno)
                    : string.Format("update TB_FORM_R3 set r_cmapproval = 'Reject', r_status = N'經管已拒絕' where r_chaseno = '{0}'", _chaseno);

                DataService.GetInstance().ExecuteNonQuery(query);

                EformUtil.SendNotificationEmail(_chaseno, "R3申請", GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), "經管已拒絕", "", 0, 0, null);

                DialogResult = DialogResult.OK;
            }
        }
        private void btnUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DataTable table = ImportExcel2007.TranslateToTable(ofd.FileName);

                List <int> invoiceIdList = new List <int>();

                foreach (DataRow row in table.Rows)
                {
                    string invoice    = row.ItemArray[0].ToString().Trim();
                    string vendor     = row.ItemArray[1].ToString().Trim();
                    string acccode    = row.ItemArray[3].ToString().Trim();
                    string costcentre = row.ItemArray[4].ToString().Trim();
                    string amount     = row.ItemArray[10].ToString().Trim();
                    string approval   = row.ItemArray[11].ToString().Trim();

                    if (approval == "Yes")
                    {
                        int    id     = GetInvoiceId(invoice);
                        string status = GetInvoiceStatus(invoice);

                        string query = status == "會計處理中" ? string.Format("update TB_ACC_OUTSTANDING_DETAIL set od_staffapproval = 'Yes' where od_o_id = '{0}' and od_accountcode = '{1}'" +
                                                                         " and od_costcentre = '{2}' and od_amount = '{3}'", id, acccode, costcentre, amount) : string.Format("update TB_ACC_OUTSTANDING_DETAIL set od_divapproval = 'Yes'" +
                                                                                                                                                                              " where od_o_id = '{0}' and od_accountcode = '{1}' and od_costcentre = '{2}' and od_amount = '{3}'", id, acccode, costcentre, amount);
                        DataServiceCM.GetInstance().ExecuteNonQuery(query);

                        invoiceIdList.Add(id);
                    }
                }

                invoiceIdList = invoiceIdList.Distinct().ToList();

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

                foreach (int item in invoiceIdList)
                {
                    string status  = GetInvoiceStatusById(item);
                    string invoice = GetInvoiceById(item);

                    string applicant = AccUtil.GetApplicant(invoice);
                    string div       = AccUtil.GetDivisionApprover(invoice);
                    string staff     = AccUtil.GetAccStaff(invoice);
                    string acc       = AccUtil.GetAccApprover(invoice);

                    if (status == "會計處理中")
                    {
                        if (IsAllItemApprovedByStaff(item))
                        {
                            string query = string.Format("update TB_ACC_OUTSTANDING set o_status = N'會計承認中', o_staffapproval = 'Yes', o_staffapprovaldate = '{0}' where o_id = '{1}'", now, item);
                            DataServiceCM.GetInstance().ExecuteNonQuery(query);

                            EformUtil.SendApprovalEmail(_invoice, applicant, AdUtil.GetEmailByUsername(applicant, "kmhk.local"), AdUtil.GetEmailByUsername(acc, "kmhk.local"), "", "Outstanding Slip - " + invoice);
                        }
                    }

                    if (status == "會計承認中")
                    {
                        if (IsAllItemApprovedByAcc(item))
                        {
                            string query = string.Format("update TB_ACC_OUTSTANDING set o_status = N'申請處理完成', o_accapproval = 'Yes', o_accapprovaldate = '{0}' where o_id = '{1}'", now, item);
                            DataServiceCM.GetInstance().ExecuteNonQuery(query);

                            EformUtil.SendFinishedEmail(_invoice, acc, AdUtil.GetEmailByUsername(acc, "kmhk.local"), AdUtil.GetEmailByUsername(applicant, "kmhk.local"), "Outstanding Slip Application Finished - " + invoice, "You Outstanding Slip Application has been finished.");
                        }
                    }
                }

                MessageBox.Show("Record has been uploaded.");
            }
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            string sectHead = UserUtil.GetSectionHead(UserUtil.GetSect(GlobalService.User));
            string divHead  = UserUtil.GetDivisionHead(UserUtil.GetDivision(GlobalService.User));

            string dept     = UserUtil.GetDept(GlobalService.User);
            string deptHead = dept.Contains("RPS") ? UserUtil.GetDepartmentHead(dept) : "";

            string cm1st = "Lee Suk Ha(李淑霞,Zoe)";
            string cm2nd = "Li Yuen Yan(李婉茵,Sharon)";

            foreach (DataGridViewRow row in dgvPreview.Rows)
            {
                string invoice = row.Cells[2].Value.ToString().Trim();
                string code    = row.Cells[0].Value.ToString().Trim();
                string name    = row.Cells[1].Value.ToString().Trim();

                string currency = AccUtil.GetVendorCurrency(code);

                string payterm = AccUtil.GetVendorPayTerm(code);

                string paydate = AccUtil.PayDate(Convert.ToDateTime(DateTime.Today.ToString("yyyy/MM/dd")), payterm);

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

                string invoiceText = string.Format("insert into TB_ACC_MASTER_INVOICE (i_invoice, i_vendor) values ('{0}', '{1}')", invoice, code);
                DataServiceCM.GetInstance().ExecuteNonQuery(invoiceText);

                string query = string.Format("insert into TB_ACC_OUTSTANDING (o_invoice, o_vendor, o_vendorname, o_inputdate, o_paymentdate, o_currency, o_amount, o_createdby" +
                                             ", o_created, o_div, o_staff, o_acc, o_sect, o_dept) values ('{0}', '{1}', N'{2}', '{3}', '{4}', '{5}', '{6}', N'{7}', '{8}', N'{9}', N'{10}', N'{11}', N'{12}', N'{13}')", invoice, code, name, DateTime.Today.ToString("yyyy/MM/dd"), paydate, currency, total,
                                             GlobalService.User, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), divHead, cm1st, cm2nd, sectHead, deptHead);

                DataServiceCM.GetInstance().ExecuteNonQuery(query);

                //KDTHK_DM_SP.utils.EformUtil.SendApprovalEmail(invoice, GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(sectHead, "kmhk.local"), "", "Outstanding Slip");
            }

            foreach (Outstanding item in dataList)
            {
                int id = AccUtil.GetOutstandingIdByInvoice(item.Invoice);

                string acName = AccUtil.GetAccountName(item.AccountCode);
                string ccName = AccUtil.GetCostCentreName(item.CostCentre);

                string desc = (item.Desc1 + item.Desc2 + item.Desc3 + item.Desc4 + item.Desc5);
                desc = desc.Substring(0, Math.Min(desc.Length, 50));

                string text = string.Format("insert into TB_ACC_OUTSTANDING_DETAIL (od_o_id, od_accountcode, od_accountname, od_costcentre, od_costcentrename, od_amount" +
                                            ", od_desc1, od_desc2, od_desc3, od_desc4, od_desc5, od_display) values ('{0}', '{1}', N'{2}', '{3}', N'{4}', '{5}', N'{6}', N'{7}', N'{8}', N'{9}', N'{10}', N'{11}')", id, item.AccountCode,
                                            acName, item.CostCentre, ccName, item.Amount, item.Desc1, item.Desc2, item.Desc3, item.Desc4, item.Desc5, desc);
                DataServiceCM.GetInstance().ExecuteNonQuery(text);
            }

            string content = "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;\">" + content + "</span></p>";

            bool isSent = false;

            if (!isSent)
            {
                isSent = true;
                KDTHK_DM_SP.utils.EformUtil.SendApprovalEmail("", GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(sectHead, "kmhk.local"), body, "Outstanding Slip");
            }

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

            DialogResult = DialogResult.OK;
        }
Esempio n. 13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string appType = cbAppType.SelectedItem.ToString().Trim();
            string reason  = txtReason.Text.Trim();

            string vendorType = cbVendorType.SelectedItem.ToString().Trim();

            string vendorCode = txtVendorCode.Text.Trim();
            string vendorName = txtVendorName.Text.Trim();

            string addr1 = txtAddr1.Text.Trim();
            string addr2 = txtAddr2.Text.Trim();
            string addr3 = txtAddr3.Text.Trim();

            string person = txtPerson.Text.Trim();
            string phone  = txtPhone.Text.Trim();
            string email  = txtEmail.Text.Trim();

            string currency = cbCurrency.SelectedItem.ToString().Trim();
            string payterm  = txtPayterm.Text.Trim();
            string fob      = cbFob.SelectedItem.ToString().Trim();

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

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

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

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

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

            string divHead = "Ho Kin Hang(何健恒,Ken)"; //UserUtil.GetDiv(GlobalService.User);

            string cm1st = "Ho Kin Hang(何健恒,Ken)";   //"Ng Wai Kwan(吳蕙君,Wendy)";
            string cm2nd = "Ho Kin Hang(何健恒,Ken)";   //"Li Yuen Yan(李婉茵,Sharon)";
            string cm3rd = "Ho Kin Hang(何健恒,Ken)";   //"Leung Wai Yip(梁偉業,Philip)";
            string cm4th = "Ho Kin Hang(何健恒,Ken)";   //"Hara Masatoshi(原雅俊)";

            string attachment = "";


            string query = string.Format("insert into TB_ACC_VENDOR (v_type, v_reason, v_vendortype, v_code, v_name, v_addr1, v_addr2, v_addr3, v_person, v_phone, v_email" +
                                         ", v_currency, v_payterm, v_fob, v_attachment, v_created, v_createdby, v_div, v_cm1st, v_cm2nd, v_cm3rd, v_cm4th) values ('{0}', N'{1}', N'{2}', '{3}', N'{4}', N'{5}', N'{6}'" +
                                         ", N'{7}', N'{8}', '{9}', '{10}', '{11}', '{12}', '{13}', N'{14}', '{15}', N'{16}', N'{17}', N'{18}', N'{19}', N'{20}', N'{21}')", appType, reason, vendorType, vendorCode, vendorName,
                                         addr1, addr2, addr3, person, phone, email, currency, payterm, fob, "", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), GlobalService.User, divHead, cm1st, cm2nd, cm3rd, cm4th);

            DataServiceCM.GetInstance().ExecuteNonQuery(query);

            EformUtil.SendApprovalEmail("", GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(divHead, "kmhk.local"), "", "Vendor Master Application - " + appType);

            DialogResult = DialogResult.OK;
        }
Esempio n. 14
0
        private void SaveData()
        {
            dgvOutstanding.EndEdit();

            string vendor     = txtVendorCode.Text.Trim();
            string vendorname = txtVendorName.Text.Trim();
            string invoice    = txtInvoice.Text.Trim();
            string currency   = cbCurr.Text;
            string indate     = dtpInput.Value.ToString("yyyy/MM/dd");
            string paydate    = dtpPaymentDate.Value.ToString("yyyy/MM/dd");
            string total      = txtAmount.Text.Trim();

            if (!AccUtil.IsVendorExists(vendor))
            {
                MessageBox.Show("Vendor: " + vendor + " does not exist. Please check your data.");
                return;
            }

            if (AccUtil.IsInvoiceExists(invoice, vendor))
            {
                MessageBox.Show("Invoice: " + invoice + " has been used.");
                return;
            }

            string signal = dtpInput.Value.Month == DateTime.Today.Month ? "True" : "False";

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

            string dept = UserUtil.GetDept(GlobalService.User);

            string deptHead = dept.Contains("RPS") ? UserUtil.GetDepartmentHead(dept) : "";

            string cm1st = "Lee Suk Ha(李淑霞,Zoe)";
            string cm2nd = "Li Yuen Yan(李婉茵,Sharon)";

            bool isValid = true;

            List <Outstanding> list = new List <Outstanding>();

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

                if (row.Cells[0].Value == null && row.Cells[2].Value == null && row.Cells[4].Value == null && row.Cells[5].Value == null && row.Cells[6].Value == null && row.Cells[7].Value == null && row.Cells[8].Value == null && row.Cells[9].Value == null)
                {
                    continue;
                }

                if (row.Cells[0].Value == null || row.Cells[2].Value == null || row.Cells[4].Value == null || row.Cells[5].Value == null)
                {
                    isValid = false;
                }

                string desc1 = "", desc2 = "", desc3 = "", desc4 = "", desc5 = "";

                try
                {
                    desc1 = row.Cells[5].Value.ToString().Trim();
                    desc2 = row.Cells[6].Value == null ? "" : row.Cells[6].Value.ToString().Trim();
                    desc3 = row.Cells[7].Value == null ? "" : row.Cells[7].Value.ToString().Trim();
                    desc4 = row.Cells[8].Value == null ? "" : row.Cells[8].Value.ToString().Trim();
                    desc5 = row.Cells[9].Value == null ? "" : row.Cells[9].Value.ToString().Trim();
                }
                catch
                {
                    isValid = false;
                }

                string acc         = row.Cells[0].Value.ToString().Trim();
                string accountcode = acc.Substring(0, 10);
                string accname     = acc.Substring(12);
                accname = accname.Substring(0, accname.Length - 1);

                string cc             = row.Cells[2].Value.ToString().Trim();
                string costcentre     = cc.Substring(0, 10);
                string costcentrename = cc.Substring(12);
                costcentrename = costcentrename.Substring(0, costcentrename.Length - 1);

                string inputAmount = row.Cells[4].Value.ToString().Trim();

                list.Add(new Outstanding {
                    VendorCode = vendor, Invoice = invoice, AccountCode = accountcode, CostCentre = costcentre, Amount = inputAmount, Desc1 = desc1, Desc2 = desc2, Desc3 = desc3, Desc4 = desc4, Desc5 = desc5
                });
            }

            if (!isValid)
            {
                MessageBox.Show("Please check the following:\n1. Select AccountCode & CostCentre.\n2. Input Amount.\n3. Remarks 1 must be input.", "Error found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string invoiceText = string.Format("insert into TB_ACC_MASTER_INVOICE (i_invoice, i_vendor) values ('{0}', '{1}')", invoice, vendor);
                DataServiceCM.GetInstance().ExecuteNonQuery(invoiceText);

                string name    = AccUtil.GetVendorName(vendor);
                string curr    = AccUtil.GetVendorCurrency(vendor);
                string payterm = AccUtil.GetVendorPayTerm(vendor);

                string query = string.Format("insert into TB_ACC_OUTSTANDING (o_invoice, o_vendor, o_vendorname, o_inputdate, o_paymentdate, o_currency, o_amount, o_createdby" +
                                             ", o_created, o_div, o_staff, o_acc, o_sect, o_dept) values ('{0}', '{1}', N'{2}', '{3}', '{4}', '{5}', '{6}', N'{7}', '{8}', N'{9}', N'{10}', N'{11}', N'{12}', N'{13}')", invoice, vendor, name, indate, paydate, currency, total,
                                             GlobalService.User, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), divHead, cm1st, cm2nd, sectHead, deptHead);
                DataServiceCM.GetInstance().ExecuteNonQuery(query);

                foreach (Outstanding item in list)
                {
                    int id = AccUtil.GetOutstandingIdByInvoice(item.Invoice);

                    string accname        = AccUtil.GetAccountName(item.AccountCode);
                    string costcentrename = AccUtil.GetCostCentreName(item.CostCentre);

                    string desc = (item.Desc1 + item.Desc2 + item.Desc3 + item.Desc4 + item.Desc5);
                    desc = desc.Substring(0, Math.Min(desc.Length, 50));

                    string text = string.Format("insert into TB_ACC_OUTSTANDING_DETAIL (od_o_id, od_accountcode, od_accountname, od_costcentre, od_costcentrename, od_amount" +
                                                ", od_desc1, od_desc2, od_desc3, od_desc4, od_desc5, od_display) values ('{0}', '{1}', N'{2}', '{3}', N'{4}', '{5}', N'{6}', N'{7}', N'{8}', N'{9}', N'{10}', N'{11}')", id, item.AccountCode,
                                                accname, item.CostCentre, costcentrename, DoFormat(item.Amount), item.Desc1, item.Desc2, item.Desc3, item.Desc4, item.Desc5, desc);
                    DataServiceCM.GetInstance().ExecuteNonQuery(text);
                }

                string content = "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;\">" + content + "</span></p>";

                KDTHK_DM_SP.utils.EformUtil.SendApprovalEmail(invoice, GlobalService.User, AdUtil.GetEmailByUsername(GlobalService.User, "kmhk.local"), AdUtil.GetEmailByUsername(sectHead, "kmhk.local"), body, "Outstanding Slip");

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

                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dgvPermission.Rows.Count == 0)
            {
                MessageBox.Show("No record found.");
                return;
            }

            dgvPermission.EndEdit();

            if (!IsDataValid(dgvPermission))
            {
                MessageBox.Show("Invalid input found.");
                return;
            }

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

            string head            = DataUtil.GetHead(applicant);
            string approval        = DataUtil.IsItemApproved(GlobalService.ChaseNo) ? "Yes" : "No";
            string strApprovalDate = DataUtil.GetApprovalDate(GlobalService.ChaseNo);

            string st = approval == "Yes" ? "I.T處理中" : "上司承認中";

            string chaseno = DataUtil.GetPermissionChaseNo();

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

                string item     = row.Cells[0].Value.ToString();
                string user     = row.Cells[1].Value.ToString();
                string start    = row.Cells[2].Value.ToString();
                string status   = row.Cells[3].Value.ToString();
                string remarks  = row.Cells[4].Value == null? "": row.Cells[4].Value.ToString();
                string assigned = row.Cells[5].Value.ToString().Trim();

                //string query = string.Format("insert into TB_FORM_PERMISSION (p_type, p_user, p_item, p_created, p_createdby, p_start, p_remarks, p_chaseno, p_approver, p_approval, p_refno, p_applicant, p_status, p_handledby)" +
                //    " values ('{0}', N'{1}', N'{2}', '{3}', N'{4}', '{5}', N'{6}', '{7}', N'{8}', '{9}', '{10}', N'{11}', N'{12}', N'{13}')", status, user, item, DateTime.Today.ToString("yyyy/MM/dd"), GlobalService.Creator, start, remarks, chaseno, head, approval, GlobalService.ChaseNo, GlobalService.Creator, st, assigned);
                string query = string.Format("insert into TB_FORM_PERMISSION (p_type, p_user, p_item, p_created, p_createdby, p_start, p_remarks, p_chaseno, p_approver, p_approval, p_refno, p_applicant, p_status, p_handledby, p_itapproval, p_approvaldate)" +
                                             " values ('{0}', N'{1}', N'{2}', '{3}', N'{4}', '{5}', N'{6}', '{7}', N'{8}', '{9}', '{10}', N'{11}', N'{12}', N'{13}', N'{14}', N'{15}')",
                                             status, user, item, DateTime.Today.ToString("yyyy/MM/dd"), GlobalService.Creator, start, remarks, chaseno, head, approval, GlobalService.ChaseNo, GlobalService.Creator, st, assigned, UserUtil.ItManagerName(), strApprovalDate);

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

            GlobalService.SavedForm = "permission";

            /*if (st == "上司承認中")
             * {
             *  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, from, to, body);
             * }*/

            if (approval == "No")
            {
                string from = AdUtil.GetEmailByUsername(applicant, "kmhk.local");
                string to   = AdUtil.GetEmailByUsername(head, "kmhk.local");

                EformUtil.SendApprovalEmail(GlobalService.ChaseNo, from, to, "Approval Required for 權限及軟件安裝", "權限及軟件安裝", applicant);
            }

            if (SavedEvent != null)
            {
                SavedEvent(this, new EventArgs());
            }
        }