コード例 #1
0
ファイル: SupportNoteDialog.cs プロジェクト: wee2tee/SN_Net
 public SupportNoteDialog(SupportStatWindow stat_windows, bool is_break, SupportNote editing_note)
     : this()
 {
     this.mode = MODE.EDIT;
     this.stat_windows = stat_windows;
     this.IS_BREAK = (is_break ? "Y" : "N");
     this.note = editing_note;
 }
コード例 #2
0
ファイル: TrainerNoteDialog.cs プロジェクト: wee2tee/SN_Net
 public TrainerNoteDialog(MainForm main_form, Users user, DateTime date, SupportNote support_note = null)
 {
     InitializeComponent();
     this.main_form = main_form;
     this.user = user;
     this.date = date;
     this.support_note = support_note;
 }
コード例 #3
0
ファイル: SupportNoteDialog.cs プロジェクト: wee2tee/SN_Net
        private void SaveToDB(SupportNote note)
        {
            bool save_success = false;
            string err_msg = string.Empty;

            string json_data = "{\"id\":" + note.id + ",";
            json_data += "\"sernum\":\"" + (note.sernum.Replace("-", "").Replace(" ", "").Length > 0 ? note.sernum.cleanString() : "") + "\",";
            json_data += "\"date\":\"" + note.date + "\",";
            json_data += "\"contact\":\"" + note.contact.cleanString() + "\",";
            json_data += "\"start_time\":\"" + note.start_time + "\",";
            json_data += "\"end_time\":\"" + note.end_time + "\",";
            json_data += "\"duration\":\"" + note.duration.Substring(0, 8) + "\",";
            json_data += "\"problem\":\"" + note.problem.cleanString() + "\",";
            json_data += "\"remark\":\"" + note.remark.cleanString() + "\",";
            json_data += "\"also_f8\":\"" + "N" + "\",";
            json_data += "\"probcod\":\"" + "" + "\",";
            json_data += "\"is_break\":\"" + this.IS_BREAK + "\",";
            json_data += "\"reason\":\"" + note.reason.cleanString() + "\",";
            json_data += "\"users_name\":\"" + note.users_name + "\",";
            json_data += "\"rec_by\":\"" + note.rec_by + "\"}";

            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                CRUDResult post;
                if (note.id < 0) // create
                {
                    post = (this.IS_BREAK == "N" ? ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/create", json_data) : ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/create_break", json_data));
                }
                else // update
                {
                    post = (this.IS_BREAK == "N" ? ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/update", json_data) : ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/update_break", json_data));
                }

                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);
                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    save_success = true;
                }
                else
                {
                    err_msg = sr.message;
                    save_success = false;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (save_success)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
                    {
                        this.SaveToDB(note);
                        return;
                    }
                    else
                    {
                        this.DialogResult = DialogResult.Cancel;
                        this.Close();
                    }
                }
            };
            worker.RunWorkerAsync();
        }
コード例 #4
0
ファイル: SupportNoteDialog.cs プロジェクト: wee2tee/SN_Net
        private void GetSupportNoteInForm()
        {
            string start_time = (this.IS_BREAK == "Y" ? this.dtBreakStart.Text : this.dtStartTime.Text);
            string end_time = (this.IS_BREAK == "Y" ? this.dtBreakEnd.Text : this.dtEndTime.Text);

            this.note = (this.note == null ? new SupportNote() { id = -1 } : this.note);

            //SupportNote note = new SupportNote()
            //{
                this.note.date = this.dtWorkDate.Value.ToMysqlDate();
                this.note.users_name = ((Users)((ComboboxItem)this.cbUser.SelectedItem).Tag).username;
                this.note.start_time = start_time;
                this.note.end_time = end_time;
                this.note.duration = TimeSpan.FromSeconds(TimeSpan.Parse(end_time).TotalSeconds - TimeSpan.Parse(start_time).TotalSeconds).ToString();
                this.note.sernum = (this.IS_BREAK == "N" ? this.txtSernum.Texts : this.txtSernum2.Texts);
                this.note.contact = this.txtContact.Texts;
                this.note.problem = this.GetProblemFormattedString();
                this.note.remark = (this.IS_BREAK == "N" ? this.txtRemark.Text : this.txtRemark2.Text);
                this.note.is_break = this.IS_BREAK;
                this.note.reason = this.GetReasonFormattedString();
                this.note.file_path = "";
                this.note.rec_by = this.stat_windows.main_form.G.loged_in_user_name;
            //};

            //return this.note;
        }
コード例 #5
0
ファイル: SupportNoteWindow.cs プロジェクト: wee2tee/SN_Net
        private void ClearForm()
        {
            this.tabControl2.SelectedTab = this.tabPage3;
            this.parent_window.btnSupportNote.Enabled = true;
            this.serial = null;
            this.note = null;
            this.ma = null;
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.WindowState = FormWindowState.Maximized;
            }
            this.splitContainer1.SplitterDistance = 42;

            #region First tab
            this.txtSernum.Texts = "";
            this.lblCompnam.Text = "";
            this.lblAddr.Text = "";
            this.lblVerext.Text = "";
            this.txtContact.Texts = "";
            this.chAlsoF8.CheckState = CheckState.Unchecked;
            this.chAssets.CheckState = CheckState.Unchecked;
            this.chError.CheckState = CheckState.Unchecked;
            this.chFonts.CheckState = CheckState.Unchecked;
            this.chForm.CheckState = CheckState.Unchecked;
            this.chInstall.CheckState = CheckState.Unchecked;
            this.chMailWait.CheckState = CheckState.Unchecked;
            this.chMapDrive.CheckState = CheckState.Unchecked;
            this.chPeriod.CheckState = CheckState.Unchecked;
            this.chPrint.CheckState = CheckState.Unchecked;
            this.chRepExcel.CheckState = CheckState.Unchecked;
            this.chSecure.CheckState = CheckState.Unchecked;
            this.chStatement.CheckState = CheckState.Unchecked;
            this.chStock.CheckState = CheckState.Unchecked;
            this.chTransferMkt.CheckState = CheckState.Unchecked;
            this.chTraining.CheckState = CheckState.Unchecked;
            this.chYearEnd.CheckState = CheckState.Unchecked;
            this.txtRemark.Text = "";
            #endregion First tab

            #region Second tab
            this.rbToilet.Checked = true;
            this.rbQt.Checked = false;
            this.rbMeetCust.Checked = false;
            this.rbTraining.Checked = false;
            this.rbCorrectData.Checked = false;
            this.rbOther.Checked = false;
            this.txtSernum2.Texts = "";
            this.lblCompnam2.Text = "";
            this.txtRemark2.Text = "";
            #endregion Second tab

            if (this.tm != null)
            {
                this.tm.Stop();
                this.tm.Enabled = false;
            }
            this.main_form.lblTimeDuration.Text = TimeSpan.Zero.ToString();
        }
コード例 #6
0
ファイル: SupportNoteWindow.cs プロジェクト: wee2tee/SN_Net
        private void toolStripEdit_Click(object sender, EventArgs e)
        {
            if (this.dgvNote.CurrentCell != null && (this.dgvNote.Rows[this.dgvNote.CurrentCell.RowIndex]).Tag is SupportNote)
            {
                this.note = (SupportNote)this.dgvNote.Rows[this.dgvNote.CurrentCell.RowIndex].Tag;

                if (((SupportNote)this.dgvNote.Rows[this.dgvNote.CurrentCell.RowIndex].Tag).is_break != "Y")
                {
                    this.tabControl1.SelectedTab = this.tabPage1;
                    this.cbProbcod.SelectedIndex = this.probcod.FindIndex(t => t.typcod == "--");

                    this.txtSernum.Texts = this.note.sernum;
                    this.dtStartTime.Text = this.note.start_time;
                    this.dtEndTime.Text = this.note.end_time;
                    this.txtRemark.Text = this.note.remark;
                    this.txtContact.Texts = this.note.contact;
                    this.CheckedProblem(this.note.problem);
                    this.txtContact.Focus();

                    if (this.txtSernum.Texts.Replace("-", "").Trim().Length > 0)
                    {
                        CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "serial/check_sn_exist&sernum=" + this.note.sernum);
                        ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);
                        if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                        {
                            if (sr.serial.Count<Serial>() > 0)
                            {
                                this.btnViewDetail.Enabled = true;
                                this.picCheck.Visible = true;
                                this.serial = sr.serial[0];
                                this.password_list = sr.serial_password;
                                this.list_problem = sr.problem;
                                this.lblCompnam.Text = this.serial.compnam;
                                this.lblAddr.Text = this.serial.addr01 + " " + this.serial.addr02 + " " + this.serial.addr03 + " " + this.serial.zipcod;
                                if (this.list_verext.Find(v => v.typcod == this.serial.verext) != null)
                                    this.lblVerext.Text = this.list_verext.Find(v => v.typcod == this.serial.verext).typcod + " : " + this.list_verext.Find(v => v.typcod == this.serial.verext).typdes_th;

                                this.FillDgvProblem();
                                if (sr.serial_password.Count > 0)
                                {
                                    this.btnViewPassword.Enabled = true;
                                }
                                else
                                {
                                    this.btnViewPassword.Enabled = false;
                                }

                                if (sr.ma.Count > 0)
                                {
                                    this.ma = sr.ma[0];
                                    this.btnMA.Enabled = true;
                                }
                                else
                                {
                                    this.ma = null;
                                    this.btnMA.Enabled = false;
                                }
                            }
                            else
                            {
                                this.btnViewDetail.Enabled = false;
                                this.btnViewPassword.Enabled = false;
                                this.picCheck.Visible = false;
                                this.serial = null;
                                this.list_problem = null;
                                this.lblCompnam.Text = "";
                                this.lblAddr.Text = "";
                                this.lblVerext.Text = "";
                                this.FillDgvProblem();
                            }
                        }
                        else
                        {
                            this.btnViewDetail.Enabled = false;
                            this.btnViewPassword.Enabled = false;
                            this.picCheck.Visible = false;
                            this.serial = null;
                            this.list_problem = null;
                            this.lblCompnam.Text = "";
                            this.lblAddr.Text = "";
                            this.lblVerext.Text = "";
                            this.FillDgvProblem();
                        }
                    }
                    else
                    {
                        this.btnViewDetail.Enabled = false;
                        this.btnViewPassword.Enabled = false;
                        this.picCheck.Visible = false;
                        this.serial = null;
                        this.list_problem = null;
                        this.lblCompnam.Text = "";
                        this.lblAddr.Text = "";
                        this.lblVerext.Text = "";
                        this.FillDgvProblem();
                    }

                    this.FormEdit();
                }
                else
                {
                    if (((SupportNote)this.dgvNote.Rows[this.dgvNote.CurrentCell.RowIndex].Tag).reason.Contains(SupportNote.BREAK_REASON.TRAINING_TRAINER.FormatBreakReson())) // if Trainer
                    {
                        TrainerNoteDialog wind = new TrainerNoteDialog(this.main_form, (Users)((ComboboxItem)this.cbUsersCode.SelectedItem).Tag, this.dtWorkDate.dateTimePicker1.Value, (SupportNote)this.dgvNote.Rows[this.dgvNote.CurrentCell.RowIndex].Tag);
                        if (wind.ShowDialog() == DialogResult.OK)
                        {
                            this.GetNote();
                        }
                    }
                    else
                    {
                        this.tabControl1.SelectedTab = this.tabPage2;
                        this.FormEditBreak();
                        this.txtSernum2.Texts = this.note.sernum;
                        this.dtBreakStart.Text = this.note.start_time;
                        this.dtBreakEnd.Text = this.note.end_time;
                        this.txtRemark2.Text = this.note.remark;
                        this.rbToilet.Checked = (this.note.reason.Contains(SupportNote.BREAK_REASON.TOILET.FormatBreakReson()) ? true : false);
                        this.rbQt.Checked = (this.note.reason.Contains(SupportNote.BREAK_REASON.QT.FormatBreakReson()) ? true : false);
                        this.rbMeetCust.Checked = (this.note.reason.Contains(SupportNote.BREAK_REASON.MEET_CUST.FormatBreakReson()) ? true : false);
                        this.rbTraining.Checked = (this.note.reason.Contains(SupportNote.BREAK_REASON.TRAINING_ASSIST.FormatBreakReson()) ? true : false);
                        this.rbCorrectData.Checked = (this.note.reason.Contains(SupportNote.BREAK_REASON.CORRECT_DATA.FormatBreakReson()) ? true : false);
                        this.rbOther.Checked = (this.note.reason.Contains(SupportNote.BREAK_REASON.OTHER.FormatBreakReson()) ? true : false);
                        this.txtRemark2.Focus();

                        this.FormEditBreak();
                    }

                }
            }
        }