Esempio n. 1
0
 private TNSSaveResult Save(bool isCopy)
 {
     _saveResult = SaveData(isCopy);
     return _saveResult;
 }
Esempio n. 2
0
 private void ReadContentProc()
 {
     _saveResult = ReadContent();
 }
Esempio n. 3
0
        private void butLuu_Click(object sender, EventArgs e)
        {
            if (_isAdd == true)
            {

                Enabled = false;
                FWWaitingMsg.LongProcess(SaveProc);
                Enabled = true;
            }
            else
            {
                _saveResult = Save(false);
            }
            switch (_saveResult)
            {
                case TNSSaveResult.SAVE_SUCCESS:
                    CloseExcel();
                    HelpMsgBox.ShowNotificationMessage("Lưu file nguồn thành công!");
                    break;
                case TNSSaveResult.SAVE_FAIL:
                    HelpMsgBox.ShowNotificationMessage("Lưu file nguồn không thành công?");
                    break;

            }
        }
Esempio n. 4
0
 private void SaveProc()
 {
     _saveResult = SaveData(false);
 }
        private DataSet ReadContent(ref TNSSaveResult result)
        {
            try
            {

                result = TNSSaveResult.VALID_EXCEL;
                DataSet ds = DATNSProgramGridSCR.I.LoadDetailDataSet(-1);
                DataTable dataTable = ds.Tables[0];
                //dataGridView1.DataSource = dataTable;
                System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

                int chanelCol = 2;
                const int chanelRow = 2;
                const int dateRow = 3;
                const int contentRow = 5;
                const int timeCol = 1;

                string chanelName;

                var channelNames = new List<string>();
                do
                {
                    Excel.Range chanel = TNSHelper.GetCell(_excelSheet, chanelRow, chanelCol);
                    chanelName = chanel.Text != null ? chanel.Text.ToString() : string.Empty;
                    if (chanelName == "") break;
                    channelNames.Add(chanelName);
                    chanelCol += chanel.MergeArea.Count;
                } while (chanelName != "");

                _notExistsChannel = TNSHelper.GetNotExistsChannel(channelNames);
                if (_notExistsChannel != "")
                {
                    result = TNSSaveResult.NOT_EXIST_CHANNEL;
                    return null;
                }

                chanelCol = 2;
                do
                {
                    Excel.Range chanel = TNSHelper.GetCell(_excelSheet, chanelRow, chanelCol);
                    chanelName = chanel.Text.ToString();
                    if (chanelName == "") break;
                    var cellMerge = chanel.MergeArea.Count;
                    var endWeekIndex = chanel.Column + cellMerge - 2;
                    for (int dateIndex = chanel.Column; dateIndex < endWeekIndex; dateIndex += 2)
                    {
                        var date = TNSHelper.GetDateValue(_excelSheet, dateRow, dateIndex) ?? (object)DBNull.Value;
                        var currentContentRow = contentRow;

                        var isBreak = false;
                        do
                        {

                            var cellCT = TNSHelper.GetCell(_excelSheet, currentContentRow, dateIndex);
                            var info = GetProgramInfo(cellCT.Value2);

                            for (int i = 0; i < cellCT.MergeArea.Count; i++)
                            {

                                object timeLine = TNSHelper.GetCell(_excelSheet, currentContentRow, timeCol).Value2;
                                if (timeLine == null || timeLine.ToString() == "")
                                {

                                    isBreak = true;
                                    break;
                                }
                                var times = TNSTimeLine.TryParse(timeLine);
                                var r = dataTable.NewRow();

                                r[TNS_PROGRAMS_GRID_SCR_CT.TIME_START] = times.Start.TimeText;
                                r[TNS_PROGRAMS_GRID_SCR_CT.MINS_START] = times.Start.TotalMinute;
                                r[TNS_PROGRAMS_GRID_SCR_CT.TIME_END] = times.End.TimeText;
                                r[TNS_PROGRAMS_GRID_SCR_CT.MINS_END] = times.End.TotalMinute;
                                r[TNS_PROGRAMS_GRID_SCR_CT.KENH_PHAT_NAME] = chanelName;
                                r[TNS_PROGRAMS_GRID_SCR_CT.NGAY_PHAT] = date;
                                r[TNS_PROGRAMS_GRID_SCR_CT.CHUONG_TRINH_NAME] = info.TenChuongTrinh;
                                r[TNS_PROGRAMS_GRID_SCR_CT.RATE_GROUP] = (object) info.Rate ?? DBNull.Value;
                                r[TNS_PROGRAMS_GRID_SCR_CT.NUOC_SX_NAME] = info.NuocSanXuat;
                                r[TNS_PROGRAMS_GRID_SCR_CT.RATE] = TNSHelper.GetFloatValue(_excelSheet,
                                                                                           currentContentRow,
                                                                                           dateIndex + 1);
                                r[TNS_PROGRAMS_GRID_SCR_CT.RATE_WEEK] =
                                    TNSHelper.GetFloatValue(_excelSheet, currentContentRow, endWeekIndex + 1);
                                dataTable.Rows.Add(r);
                                Application.DoEvents();
                                currentContentRow++;
                            }
                            if (isBreak)
                                break;

                        } while (true);

                    }
                    chanelCol += cellMerge;
                } while (chanelName != "");

                System.Threading.Thread.CurrentThread.CurrentCulture = _oldCi;

                return ds;
            }
            catch (Exception)
            {
                result = TNSSaveResult.INVALID_EXCEL;
            }
            return null;
        }
        private void butLuu_Click(object sender, EventArgs e)
        {
            if (_isAdd == true)
            {
                Enabled = false;
                FWWaitingMsg.LongProcess(SaveProc);
                CloseExcel();
                Enabled = true;
            }
            else
            {
                _saveResult = Save(false);
            }
            switch (_saveResult)
            {
                case TNSSaveResult.SAVE_SUCCESS:
                    HelpMsgBox.ShowNotificationMessage("Lưu file nguồn thành công!");
                    break;
                case TNSSaveResult.SAVE_FAIL:
                    HelpMsgBox.ShowNotificationMessage("Lưu file nguồn không thành công?");
                    break;
                case TNSSaveResult.INVALID_DATA:
                    HelpPhieuMsg.ShowInvalidData();
                    break;
                case TNSSaveResult.NOT_EXIST_CHANNEL:
                    TNSHelper.ShowMessageNotExistChannel(this, _notExistsChannel);
                    break;
                case TNSSaveResult.INVALID_EXCEL:
                    TNSHelper.ShowInvalidExcel();
                    break;

            }
        }