コード例 #1
0
        private DataTable GetCSVData(DateTime from, DateTime to)
        {
            Controllers.frm35Controller o35 = new Controllers.frm35Controller();
            DataTable dt = o35.getAccountingCSV(from, to);

            return(dt);
        }
コード例 #2
0
 private void BindGrid(DateTime from, DateTime to)
 {
     try
     {
         Controllers.frm35Controller oController = new Controllers.frm35Controller();
         dtCheckResult = oController.GetMatchInvoice(fromDate, toDate, chkNoReserved.Checked);
         if (dtCheckResult.Rows.Count > 0)
         {
             dgvList.DataSource = dtCheckResult;
             this.dgvList.ColumnHeadersHeightSizeMode             = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
             this.dgvList.ColumnHeadersHeightSizeMode             = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
             this.dgvList.ColumnHeadersHeight                     = 40;
             this.dgvList.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
             this.dgvList.Columns[0].Width = 25;
         }
         else
         {
             //clear data except headers
             var empty = dgvList.DataSource as DataTable;
             try
             {
                 empty.Rows.Clear();
             }
             catch (Exception)//handle null result on first search
             {
             }
             dgvList.DataSource = empty;
         }
     }
     catch (System.TimeoutException)
     {
         MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (System.Net.WebException)
     {
         MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         Utility.WriteErrorLog(ex.Message, ex, false);
         MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Search Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
        private void BtnCancelAllocation_Click(object sender, EventArgs e)
        {
            #region CheckSelectedRow
            int status     = 0;
            int index      = 0;
            int foundindex = 0;
            foreach (DataGridViewRow row in dgvList.Rows)
            {
                if (row.Cells["colCheck"].Value == null ? false : bool.Parse(row.Cells["colCheck"].Value.ToString()))
                {
                    if (status >= 1) //if already found
                    {
                        status = 2;
                    }
                    else //first selected
                    {
                        status     = 1;
                        foundindex = index;
                    }
                }
                index++;
            }
            #endregion

            if (status == 0) //if no row selected
            {
                MetroMessageBox.Show(this, "\n" + Messages.ComparisonResultDetail.NoSelectedRow, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("SEQ_NO");
                    dt.Columns.Add("COMPANY_NO_BOX");
                    dt.Columns.Add("YEAR_MONTH");

                    string strCompanyNoBox = "";
                    int    intseqno        = 0;
                    string strYearMonth    = "";

                    for (int i = 0; i < dgvList.Rows.Count; i++) //get selected items
                    {
                        bool value = bool.Parse(dgvList[0, i].Value == null ? "false" : dgvList[0, i].Value.ToString());
                        if (value == true)
                        {
                            strCompanyNoBox = dgvList.Rows[i].Cells["COMPANY_NO_BOX"].Value.ToString();
                            intseqno        = int.Parse(dgvList.Rows[i].Cells["SEQ_NO"].Value.ToString());
                            strYearMonth    = dgvList.Rows[i].Cells["YEAR_MONTH"].Value.ToString();

                            DataRow dr = dt.NewRow();
                            dr["SEQ_NO"]         = intseqno;
                            dr["COMPANY_NO_BOX"] = strCompanyNoBox;
                            dr["YEAR_MONTH"]     = strYearMonth;
                            dt.Rows.Add(dr);
                        }
                    }

                    Controllers.frm35Controller oController = new Controllers.frm35Controller();
                    bool success = oController.CancelAllocation(dt);
                    if (success)
                    {
                        btnCheckTheResult.PerformClick();
                        MetroMessageBox.Show(this, "\n" + Messages.ComparisonResultDetail.StatusUpdatedToCancel, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (System.TimeoutException)
                {
                    MetroMessageBox.Show(this, "\n" + Messages.General.ServerTimeOut, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (System.Net.WebException)
                {
                    MetroMessageBox.Show(this, "\n" + Messages.General.NoConnection, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    Utility.WriteErrorLog(ex.Message, ex, false);
                    MetroMessageBox.Show(this, "\n" + Messages.General.ThereWasAnError, "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }