private void btnStart_Click(object sender, EventArgs e)
        {
            DataTable dt = FunctionENG.getDataTableFromExcel(txtImportFile.Text.Trim());

            if (dt.Rows.Count > 0)
            {
                progressBar1.Maximum = dt.Rows.Count;
                progressBar1.Value   = 0;

                foreach (DataRow dr in dt.Rows)
                {
                    progressBar1.Value += 1;
                    lblProgress.Text    = "App No: " + dr["app_no"].ToString() + "   Current Row:" + progressBar1.Value + "   Total Row:" + dt.Rows.Count;
                    Application.DoEvents();

                    string AppNo = dr["app_no"].ToString();
                    TsFileRequisitionInfoLinqDB infLnq = new TsFileRequisitionInfoLinqDB();
                    infLnq.ChkDataByAPP_NO_MS_REQUISITION_TYPE_ID(AppNo, Convert.ToInt64(cbReqType.SelectedValue), null);

                    if (infLnq.ID > 0)
                    {
                        infLnq.SEND_DATE = dtSendDate.Value.Date;

                        bool          re    = true;
                        TransactionDB trans = new TransactionDB();
                        re = infLnq.UpdateByPK("UpdateSendDate", trans.Trans);

                        if (re == false)
                        {
                            trans.RollbackTransaction();
                            //MessageBox.Show(infLnq.ErrorMessage + "  เลขที่คำขอ:" + AppNo + "   RowID:" + progressBar1.Value);
                            Engine.Common.FunctionEng.CreateLogFile(Application.StartupPath + @"\ImportError_" + DateTime.Now.ToString("yyyyMMdd") + ".txt", "AppNo=" + AppNo + "  " + infLnq.ErrorMessage);
                            continue;
                        }
                        else
                        {
                            trans.CommitTransaction();
                        }
                    }
                }

                MessageBox.Show("Complete");
            }
        }
        public void SendMail(string allID)
        {
            //LiveFaceScan.userinfo.email = "*****@*****.**";
            //LiveFaceScan.userinfo.id = 16 + "";
            Boolean ret;
            ret =false;
            EbrochureDocumentLinqDB  eDocument = new EbrochureDocumentLinqDB();

            TransactionDB trans = new TransactionDB();
            //trans.CreateTransaction();
            string status;
            status = "false";
            string[] strId = allID.Split(',');

            //for (int i = 0; i < strId.Length; i++) {
               EbrochureSendMailJobLinqDB SendMailJob = new EbrochureSendMailJobLinqDB();

                //SendMailJob.CREATE_BY = "Admin";
                //SendMailJob.CREATE_ON = DateTime.Now;
                //SendMailJob.UPDATE_BY = "Admin";
                //SendMailJob.UPDATE_ON = DateTime.Now;
                SendMailJob.ERM_TS_PERSONAL_INFO_ID = Convert.ToInt32( LiveFaceScan.userinfo.id);
                SendMailJob.CUSTOMER_EMAIL = LiveFaceScan.userinfo.email;
                SendMailJob.IS_SEND_MAIL = 'N';
                ret = SendMailJob.InsertData("Admin", trans.Trans);

                if (ret == true)
                {
                    //DataTable dt;
                    //dt = eDocument.GetDataList("ebrochure_id=" + strId[0], "", trans.Trans);

                    //for (int j = 0; j < dt.Rows.Count; j++)
                    //{
                      for (int i = 0; i < strId.Length; i++) {
                        EbrochureSendMailJobItemLinqDB SendMailJobItem = new EbrochureSendMailJobItemLinqDB();
                        //SendMailJobItem.CREATE_BY = "Admin";
                        //SendMailJobItem.CREATE_ON = DateTime.Now;
                        //SendMailJob.UPDATE_BY = "Admin";
                        //SendMailJob.UPDATE_ON = DateTime.Now;
                        SendMailJobItem.EBROCHURE_SEND_MAIL_JOB_ID = SendMailJob.ID;
                        SendMailJobItem.EBROCHURE_ID = Convert.ToInt32(strId[i]);
                        ret = SendMailJobItem.InsertData("Admin", trans.Trans);

                        SendMailJobItem = null;
                        }
                }

                SendMailJob = null;
            //}

            if (ret == false)
            {
                trans.RollbackTransaction();
                MessageBox.Show("ไม่สามารถส่ง E-Mail ได้");
            }
            else {
                trans.CommitTransaction();
                this.Visible = false;
                this.Close();

               frmEmailSend f = new frmEmailSend();
                f.MailComplete();
                f.ShowDialog();

            }
        }
        public void RenderBrochure()
        {
            int iWidth = 587;
            int iHeight = 800;
            int iy = 224;

            panel1.Location = new Point(40, 322);
            panel1.Height = iHeight;
            panel1.Width = 750;

            iy = iy + iHeight;

            this.Width = 800;
            this.Height = 1224;
            pictureEmail.Location = new Point(221, iy + 100);

            //245, 653
            TransactionDB trans = new TransactionDB();
            //trans.CreateTransaction();

            EbrochureLinqDB brochure = new EbrochureLinqDB();
            DataTable dt;
            dt = brochure.GetDataList("", "", trans.Trans);
            trans.CommitTransaction();
            x = 0;
            y  =0 ;
            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                AddItem(dt.Rows[i]["id"] + "", dt.Rows[i]["name_thai"] + "");
                // ++i;
            }
               // AddItem(1, "Service");
            //AddItem2(1, "count_queue");
            //AddItem3(1, "wait_time");
            //AddItem4(1, "app_queue");

            dt.Dispose();
            //FLP.Show();
            panel1.Show();
        }
        public void OpenBrochure(Object Sender, EventArgs e)
        {
            Label lbl = (Label)Sender;
            TransactionDB transList = new TransactionDB();

            EbrochureDocumentLinqDB Document = new EbrochureDocumentLinqDB();
            DataTable dt;
            dt = Document.GetDataList("ebrochure_id=" + lbl.Name, "", transList.Trans);
            transList.CommitTransaction();
            if (dt.Rows.Count > 0) {

                frmOpenBrochure f = new frmOpenBrochure();
                f.ShowContent(dt.Rows[0]["file_path"] + "", GetBrochureName(dt.Rows[0]["ebrochure_id"] + ""));
                f.ShowDialog();
            }
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (txtImportFile.Text.Trim() == "")
            {
                MessageBox.Show("กรุณาเลือกไฟล์ที่ต้องการนำเข้าข้อมูล");
                return;
            }


            IEDriver sIE = new IEAutomation.IEDriver();

            IE = sIE.GetIEBrowser("iexplore", "https://epatent.ipthailand.go.th/ePatent/App-Exam/DocImageAll.aspx");
            if (IE == null)
            {
                IE = sIE.GetIEBrowser("iexplore", "https://10.10.18.171/ePatent/App-Exam/DocImageAll.aspx");
            }
            if (IE == null)
            {
                IE = sIE.GetIEBrowser("iexplore", "http://epatent.ipthailand.go.th/ePatent/App-Exam/DocImageAll.aspx");
            }
            if (IE == null)
            {
                IE = sIE.GetIEBrowser("iexplore", "http://10.10.18.171/ePatent/App-Exam/DocImageAll.aspx");
            }

            if (IE != null)
            {
                DataTable dt = FunctionENG.getDataTableFromExcel(txtImportFile.Text.Trim());
                if (dt.Rows.Count > 0)
                {
                    progressBar1.Maximum = dt.Rows.Count;
                    progressBar1.Value   = 0;

                    foreach (DataRow dr in dt.Rows)
                    {
                        progressBar1.Value    += 1;
                        lblProgressStatus.Text = "App No: " + dr["app_no"].ToString() + "   Current Row:" + progressBar1.Value + "   Total Row:" + dt.Rows.Count;
                        Application.DoEvents();

                        string AppNo          = dr["app_no"].ToString();
                        string ReqTypeName    = dr["requisition_type_name"].ToString();
                        string PatentTypeName = dr["patent_type_name"].ToString();
                        //DateTime PrepareDate = Engine.Common.FunctionEng.cStrToDateTime3(dr["prepare_date"].ToString());
                        //DateTime SendDate = Engine.Common.FunctionEng.cStrToDateTime3(dr["send_date"].ToString());
                        RequisitionDateInfo DateInfo = GetRequisitionDateInfo(AppNo);

                        try
                        {
                            MsRequisitionTypeLinqDB rqLnq = new MsRequisitionTypeLinqDB();
                            rqLnq.ChkDataByWhere("requisition_type_name='" + ReqTypeName + "'", null);
                            if (rqLnq.ID == 0)
                            {
                                MessageBox.Show("ไม่พบข้อมูลประเภทคำขอ " + ReqTypeName + "  เลขที่คำขอ:" + AppNo + "   RowID:" + progressBar1.Value);
                                return;
                            }

                            MsPatentTypeLinqDB ptLnq = new MsPatentTypeLinqDB();
                            ptLnq.ChkDataByWhere("patent_type_name = '" + PatentTypeName + "'", null);
                            if (ptLnq.ID == 0)
                            {
                                MessageBox.Show("ไม่พบข้อมูลประเภทแฟ้ม " + PatentTypeName + "  เลขที่คำขอ:" + AppNo + "   RowID:" + progressBar1.Value);
                                return;
                            }

                            TsFileRequisitionInfoLinqDB infLnq = new TsFileRequisitionInfoLinqDB();
                            infLnq.ChkDataByAPP_NO_MS_REQUISITION_TYPE_ID(AppNo, rqLnq.ID, null);

                            infLnq.APP_NO = AppNo;
                            if (DateInfo.FILING_DATE.Year != 1)
                            {
                                infLnq.FILING_DATE = DateInfo.FILING_DATE;
                            }
                            if (DateInfo.RECEIVE_DATE.Year != 1)
                            {
                                infLnq.RECEIVE_DATE = DateInfo.RECEIVE_DATE;
                            }
                            infLnq.MS_REQUISITION_TYPE_ID = rqLnq.ID;
                            infLnq.MS_PATENT_TYPE_ID      = ptLnq.ID;
                            //infLnq.PREPARE_DATE = PrepareDate;
                            //infLnq.SEND_DATE = SendDate;

                            bool          re    = true;
                            TransactionDB trans = new TransactionDB();
                            if (infLnq.ID == 0)
                            {
                                re = infLnq.InsertData("Import", trans.Trans);
                            }
                            else
                            {
                                re = infLnq.UpdateByPK("Import", trans.Trans);
                            }

                            if (re == false)
                            {
                                trans.RollbackTransaction();
                                //MessageBox.Show(infLnq.ErrorMessage + "  เลขที่คำขอ:" + AppNo + "   RowID:" + progressBar1.Value);
                                Engine.Common.FunctionEng.CreateLogFile(Application.StartupPath + @"\ImportError_" + DateTime.Now.ToString("yyyyMMdd") + ".txt", "AppNo=" + AppNo + "  " + infLnq.ErrorMessage);
                                continue;
                            }

                            sIE.SetInputStringValue("ctl00$MainContent$txtAppNo", AppNo);
                            sIE.ClickButton("ctl00$MainContent$btnSearch");

                            HTMLTable tb = sIE.GetTableElement("ctl00_MainContent_gvMain");
                            if (tb.rows.length > 1)
                            {
                                TsFileScanSummaryLinqDB lnq = new TsFileScanSummaryLinqDB();
                                DataTable tmpDt             = lnq.GetDataList("app_no='" + AppNo + "'", "", trans.Trans);
                                if (tmpDt.Rows.Count > 0)
                                {
                                    //TransactionDB trans = new TransactionDB();
                                    foreach (DataRow tmpDr in tmpDt.Rows)
                                    {
                                        re = lnq.DeleteByPK(Convert.ToInt64(tmpDr["id"]), trans.Trans);
                                        if (re == false)
                                        {
                                            break;
                                        }
                                    }
                                    if (re == false)
                                    {
                                        trans.RollbackTransaction();
                                    }
                                    lnq = null;
                                }

                                if (re == true)
                                {
                                    int iRow = 0;
                                    foreach (HTMLTableRow tbr in tb.rows)
                                    {
                                        if (iRow == 0)
                                        {
                                            iRow += 1;
                                            continue;
                                        }

                                        HTMLTableCell CellReqNo      = (HTMLTableCell)tbr.cells.item(2);
                                        HTMLTableCell CellReqType    = (HTMLTableCell)tbr.cells.item(3);
                                        HTMLTableCell CellFilingDate = (HTMLTableCell)tbr.cells.item(4);
                                        HTMLTableCell CellImportDate = (HTMLTableCell)tbr.cells.item(5);
                                        HTMLTableCell CellDocType    = (HTMLTableCell)tbr.cells.item(9);
                                        HTMLTableCell CellPageQty    = (HTMLTableCell)tbr.cells.item(10);
                                        //HTMLTableCell CellVersion = (HTMLTableCell)tbr.cells.item(11);

                                        string ReqNo      = CellReqNo.innerHTML.Trim();
                                        string ReqType    = CellReqType.innerHTML.Trim();
                                        string FilingDate = CellFilingDate.innerHTML.Trim();
                                        string ImportDate = CellImportDate.innerHTML.Trim();
                                        string DocType    = CellDocType.innerHTML.Trim();
                                        string PageQty    = CellPageQty.innerHTML.Trim();
                                        string vVersion   = GetString((HTMLTableCell)tbr.cells.item(11));

                                        //string vData = "AppNo=" + AppNo + ": PatentType=" + PatentType + ": FilingDate=" + FilingDate + ": ImportDate=" + ImportDate + ": " + DocType + ": PageQty=" + PageQty + ": Verion=" + vVersion;

                                        //Engine.Common.FunctionEng.CreateLogFile(vData);
                                        lnq        = new TsFileScanSummaryLinqDB();
                                        lnq.APP_NO = AppNo;
                                        lnq.REQ_NO = ReqNo;
                                        lnq.REQUISITION_TYPE_NAME = ReqType;
                                        lnq.FILING_DATE           = Engine.Common.FunctionEng.cStrToDateTime2(FilingDate);
                                        lnq.IMPORT_DATE           = Engine.Common.FunctionEng.cStrToDateTime2(ImportDate);
                                        lnq.DOC_TYPE_NAME         = DocType;
                                        lnq.PAGE_QTY    = Convert.ToInt64(PageQty);
                                        lnq.DOC_VERSION = vVersion;

                                        re = lnq.InsertData("Import", trans.Trans);
                                        if (re == false)
                                        {
                                            Engine.Common.FunctionEng.CreateLogFile(Application.StartupPath + @"\ImportError_" + DateTime.Now.ToString("yyyyMMdd") + ".txt", "AppNo=" + AppNo + "  " + infLnq.ErrorMessage);
                                            continue;
                                        }
                                        iRow += 1;
                                    }
                                }
                            }

                            if (re == true)
                            {
                                trans.CommitTransaction();
                            }
                            else
                            {
                                trans.RollbackTransaction();
                            }
                        }
                        catch (Exception ex)
                        {
                            Engine.Common.FunctionEng.CreateLogFile(Application.StartupPath + @"\ImportError_" + DateTime.Now.ToString("yyyyMMdd") + ".txt", ex.Message + "\n" + ex.StackTrace);
                        }
                    }
                    MessageBox.Show("Complete");
                }
            }
            else
            {
                MessageBox.Show("กรุณาเปิดระบบ ePatent และเข้าหน้าจอ เมนูหลัก > แสดงเอกสาร");
            }
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (validate() == false) return;

        String strServerName = ConfigurationManager.AppSettings["ServerName"];
        String strDbName = ConfigurationManager.AppSettings["DbName"];
        String strDbUserID = ConfigurationManager.AppSettings["DbUserID"];
        String strDbPwd = ConfigurationManager.AppSettings["DbPwd"];

        SqlConnection objConn = new SqlConnection("Data Source=" + strServerName +";Initial Catalog=" + strDbName +";User ID=" +strDbUserID + ";password="******"0")
        {
            String strSql = "";
            strSql = "Select Count(*) From ERM_TS_Personal_info Where first_name='" + txtFirstName.Text + "' And last_name='" + txtLastName.Text + "'";
            SqlCommand objCmd = new SqlCommand(strSql, objConn);
            String Result = Convert.ToString(objCmd.ExecuteScalar());
            if (Result != "0")
            {
                Config.SetAlert("ชื่อนี้ได้ทำการลงทะเบียนแล้ว", this);
                return;
            }

            strSql = "Select Count(*) From ERM_TS_Personal_info Where Email='" + txtEmail.Text + "' ";
            objCmd = new SqlCommand(strSql, objConn);
            Result = Convert.ToString(objCmd.ExecuteScalar());
            if (Result != "0")
            {
                Config.SetAlert("อีเมลล์นี้ได้ทำการลงทะเบียนแล้ว", this);
                return;
            }

            strSql = "Select Count(*) From ERM_TS_Personal_info Where Mobile_No='" + txtMobileNo.Text + "' ";
            objCmd = new SqlCommand(strSql, objConn);
            Result = Convert.ToString(objCmd.ExecuteScalar());
            if (Result != "0")
            {
                Config.SetAlert("เบอร์โทรนี้ได้ทำการลงทะเบียนแล้ว", this);
                return;
            }
        }

        int intChkA = 0;
        int intChkB = 0;
        int intChkC = 0;
        int intChkD = 0;
        int intChkE = 0;

        if ((rdPeriod.Items[0].Selected == false) && (rdPeriod.Items[1].Selected == false))
        {
            Config.SetAlert("กรุณาเลือกช่วงเวลาเข้าร่วมงาน", this);
            return;
        }

        if (ChkA01.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA02.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA03.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA04.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA05.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA06.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA07.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA08.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA09.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA10.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA11.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA12.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA13.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA14.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA15.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA16.Checked == true)
        {
            intChkA += 1;
        }
        if (ChkA17.Checked == true)
        {
            intChkA += 1;
        }

        if (ChkB01.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB02.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB03.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB04.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB05.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB06.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB07.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB08.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB09.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB10.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB11.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB12.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB13.Checked == true)
        {
            intChkB += 1;
        }
        if (ChkB14.Checked == true)
        {
            intChkB += 1;
        }

        if (ChkC01.Checked == true)
        {
            intChkC += 1;
        }
        if (ChkC02.Checked == true)
        {
            intChkC += 1;
        }
        if (ChkC03.Checked == true)
        {
            intChkC += 1;
        }
        if (ChkC04.Checked == true)
        {
            intChkC += 1;
        }
        if (ChkC05.Checked == true)
        {
            intChkC += 1;
        }
        if (ChkC06.Checked == true)
        {
            intChkC += 1;
        }
        if (ChkC07.Checked == true)
        {
            intChkC += 1;
        }

        if (ChkD01.Checked == true)
        {
            intChkD += 1;
        }
        if (ChkD02.Checked == true)
        {
            intChkD += 1;
        }

        if (ChkE01.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE02.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE03.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE04.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE05.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE06.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE07.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE08.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE09.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE10.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE11.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE12.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE13.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE14.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE15.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE16.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE17.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE18.Checked == true)
        {
            intChkE += 1;
        }
        if (ChkE19.Checked == true)
        {
            intChkE += 1;
        }

        if (intChkA == 0)
        {
            Config.SetAlert("กรุณาระบุประเภทธุรกิจของท่าน", this);
            return;
        }

        if (intChkB == 0)
        {
            Config.SetAlert("กรุณาระบุช่องทางการได้รับข่าวสาร", this);
            return;
        }

        if (intChkC == 0)
        {
            Config.SetAlert("กรุณาระบุวัตถุประสงค์ของการเข้าชมงาน", this);
            return;
        }

        if (intChkD == 0)
        {
            Config.SetAlert("กรุณาระบุความต้องการการเข้าชม", this);
            return;
        }

        if (intChkE == 0)
        {
            Config.SetAlert("กรุณาระบุประเภทสินค้าหรือบริการที่ท่านสนใจ", this);
            return;
        }

        //Page.Form.DefaultFocus = txtFirstName.ClientID;

        ErmTsPersonalInfoPara Erm = new ErmTsPersonalInfoPara();
        if (lblid.Text != "0")
        {
            Erm.ID =  Convert.ToInt64(lblid.Text);
        }
        Erm.IDCARD_NO = "0"; //txtIDCardNo.Text;
        Erm.TITLE_NAME = rdiTitle.SelectedValue;
        if (rdiTitle.SelectedValue == "OTHERS")
        {
            Erm.TITLE_NAME = txtTitleOthers.Text;
        }
        Erm.FIRST_NAME = txtFirstName.Text;
        Erm.MIDDLE_NAME = "";// txtMiddleName.Text;
        Erm.LAST_NAME = txtLastName.Text;
        Erm.POSITION_NAME = txtPosition.Text;
        Erm.COMPANY_NAME = txtCompany.Text;
        Erm.ADDRESS = txtAddress.Text;
        Erm.CITY = txtCity.Text;
        Erm.STATE = "";//txtState.Text;
        Erm.COUNTRY = txtCountry.Text;
        Erm.ZIPCODE = txtZipCode.Text;
        Erm.TELNO = txtTelNumber.Text;
        Erm.FAXNO = txtFaxNumber.Text;
        Erm.EMAIL = txtEmail.Text;
        Erm.WEBSITE = txtWebSite.Text;
        Erm.DIVISION = txtDivition.Text;
        Erm.MOBILE_NO = txtMobileNo.Text;
        if ((rdPeriod.Items[0].Selected == true) && (rdPeriod.Items[1].Selected == true))
        {
            Erm.REGISPERIOD = "3";
        }
        else
        {
               Erm.REGISPERIOD = rdPeriod.SelectedValue;
        }

           // if (txtRegisteredCapital.Text != "")
            Erm.REGISTERED_CAPITAL = 0;//Convert.ToDouble(txtRegisteredCapital.Text);

        Erm.ANNUAL_SALE_VALUE_YEAR = DateTime.Today.Year;
        Erm.ANNUAL_SALE_VALUE_VOLUMNS = rdAnnualSale.SelectedValue;

        TransactionDB Trans = new TransactionDB();
        Engine.Questionnaire.RegisterENG eng = new Engine.Questionnaire.RegisterENG();

        long id;
        id = eng.SavePersonalInfo(Erm, "Register", Trans);
        if (id > 0)
        {

            bool IsDel = true;
            IsDel = eng.DeleteInterest(id, Trans);
            if (IsDel == false)
            {
                Trans.RollbackTransaction();
                ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('ไม่สามารถบันทึกข้อมูลได้');", true);
                return;
            }

            SaveDetail(ChkA01, id, Trans,"","A");
            SaveDetail(ChkA02, id, Trans, "", "A");
            SaveDetail(ChkA03, id, Trans, "", "A");
            SaveDetail(ChkA04, id, Trans, "", "A");
            SaveDetail(ChkA05, id, Trans, "", "A");
            SaveDetail(ChkA06, id, Trans, "", "A");
            SaveDetail(ChkA07, id, Trans, "", "A");
            SaveDetail(ChkA08, id, Trans, "", "A");
            SaveDetail(ChkA09, id, Trans, "", "A");
            SaveDetail(ChkA10, id, Trans, txtA10.Text, "A");
            SaveDetail(ChkA11, id, Trans, "", "A");
            SaveDetail(ChkA12, id, Trans, "", "A");
            SaveDetail(ChkA13, id, Trans, "", "A");
            SaveDetail(ChkA14, id, Trans, "", "A");
            SaveDetail(ChkA15, id, Trans, "", "A");
            SaveDetail(ChkA16, id, Trans, "", "A");
            SaveDetail(ChkA17, id, Trans, txtA17.Text, "A");

            SaveDetail(ChkB01, id, Trans, "", "B");
            SaveDetail(ChkB02, id, Trans, "", "B");
            SaveDetail(ChkB03, id, Trans, "", "B");
            SaveDetail(ChkB04, id, Trans, txtB04.Text, "B");
            SaveDetail(ChkB05, id, Trans, txtB05.Text, "B");
            SaveDetail(ChkB06, id, Trans, txtB06.Text, "B");
            SaveDetail(ChkB07, id, Trans, "", "B");
            SaveDetail(ChkB08, id, Trans, "", "B");
            SaveDetail(ChkB09, id, Trans, "", "B");
            SaveDetail(ChkB10, id, Trans, "", "B");
            SaveDetail(ChkB11, id, Trans, "", "B");
            SaveDetail(ChkB12, id, Trans, "", "B");
            SaveDetail(ChkB13, id, Trans, "", "B");
            SaveDetail(ChkB14, id, Trans, txtB14.Text, "B");

            SaveDetail(ChkC01, id, Trans, "", "C");
            SaveDetail(ChkC02, id, Trans, "", "C");
            SaveDetail(ChkC03, id, Trans, "", "C");
            SaveDetail(ChkC04, id, Trans, "", "C");
            SaveDetail(ChkC05, id, Trans, "", "C");
            SaveDetail(ChkC06, id, Trans, "", "C");
            SaveDetail(ChkC07, id, Trans, txtC07.Text, "C");

            SaveDetail(ChkD01, id, Trans, "", "D");
            SaveDetail(ChkD02, id, Trans, txtD02.Text, "D");

            SaveDetail(ChkE01, id, Trans, "", "E");
            SaveDetail(ChkE02, id, Trans, "", "E");
            SaveDetail(ChkE03, id, Trans, "", "E");
            SaveDetail(ChkE04, id, Trans, "", "E");
            SaveDetail(ChkE05, id, Trans, "", "E");
            SaveDetail(ChkE06, id, Trans, "", "E");
            SaveDetail(ChkE07, id, Trans, "", "E");
            SaveDetail(ChkE08, id, Trans, "", "E");
            SaveDetail(ChkE09, id, Trans, "", "E");
            SaveDetail(ChkE10, id, Trans, "", "E");
            SaveDetail(ChkE11, id, Trans, "", "E");
            SaveDetail(ChkE12, id, Trans, "", "E");
            SaveDetail(ChkE13, id, Trans, "", "E");
            SaveDetail(ChkE14, id, Trans, "", "E");
            SaveDetail(ChkE15, id, Trans, "", "E");
            SaveDetail(ChkE16, id, Trans, "", "E");
            SaveDetail(ChkE17, id, Trans, "", "E");
            SaveDetail(ChkE18, id, Trans, "", "E");
            SaveDetail(ChkE19, id, Trans, "", "E");

            Trans.CommitTransaction();

            bool ret = false;
            ret = clsSendMail.SendEmailMessage(txtEmail.Text, "*****@*****.**", "mail.scoresolutions.co.th", "1qaz@WSX", txtFirstName.Text + " " + txtLastName.Text, id.ToString(), Server.MapPath("~/image/PrintAdsTheretrunofRFIDHERO_Resize.jpg"), 25, false, Server.MapPath("~/image/logo.png"));

            if (ret == false)
            {
                ret = clsSendMail.SendEmailMessage(txtEmail.Text, "*****@*****.**", "smtp.live.com", "1qaz@WSX", txtFirstName.Text + " " + txtLastName.Text, id.ToString(), Server.MapPath("~/image/PrintAdsTheretrunofRFIDHERO_Resize.jpg"), 587, true, Server.MapPath("~/image/logo.png"));
            }

            if (ret == true)
            {
                Trans = new TransactionDB();
                if (eng.UpdateIsSendMail(id, "Register", Trans) == true)
                {
                    Trans.CommitTransaction();
                }
                else
                {
                    Trans.RollbackTransaction();
                }
            }
            eng = null;

            //Response.Redirect("../WebApp/frmRegisterComplete.aspx?id=" + Convert.ToString(id));
            //Config.ShowModalDialog("../WebApp/frmRegisterEmailComplete.aspx?id=" +id, this);
            Config.RedirecPage("../WebApp/frmRegisterEmailComplete.aspx?id=" + id, this);
            Clear();
        }

        else {
            Trans.RollbackTransaction();
            Config.SetAlert("ไม่สามารถบันทึกข้อมูลได้",this);
             }
    }
예제 #7
0
        public static bool InsertPrintJob(long PersonalID, string CreateBy, bool IsReprint) {
            bool ret = false;
            try {
                string sql = "insert into tb_print_job (create_by,create_on,erm_ts_personal_info_id,print_job_date,printed_date) ";
                sql += " values('" + CreateBy + "',getdate(), '" + PersonalID + "',getdate()";
                if (IsReprint == true) {
                    sql += ",getdate()";
                }else{
                    sql += ", null";
                }
                sql += " )";
                TransactionDB trans = new TransactionDB();
                ret = (Linq.Common.Utilities.SqlDB.ExecuteNonQuery(sql, trans.Trans) > -1);
                if (ret == true)
                {
                    trans.CommitTransaction();
                }
                else {
                    trans.RollbackTransaction();
                }
            }
            catch (Exception ex) {
                ret = false;
            }

            return ret;
        }