Example #1
0
 private void CheckAndLoadCashRegister()
 {
     try
     {
         string    dateToday = DateTime.Now.ToString("yyyy-MM-dd");
         string    Query     = "select * from tblMoneyEntry where branchCode = '" + BranchCode + "' and datecreated between '" + dateToday + " 00:00:00' and '" + dateToday + " 23:59:59' and isActive = 1";
         DataTable dtRecords = cf.GetRecords(Query, "client");
         if (dtRecords.Rows.Count > 0)
         {
             textBox1.Text = dtRecords.Rows[0]["OnRegisterMoney"].ToString();
             string    Detail_ID       = dtRecords.Rows[0]["sysID"].ToString();
             string    QueryDetails    = "select * from tblMoneyEntryDetails where moneyEntryID =" + Detail_ID + " order by sysid";
             DataTable dtRecordDetails = cf.GetRecords(QueryDetails, "client");
             if (dtRecordDetails.Rows.Count > 0)
             {
                 foreach (DataRow drow in dtRecordDetails.Rows)
                 {
                     string          MoneyValue    = drow["MoneyValue"].ToString();
                     string          MoneyQuantity = drow["Quantity"].ToString();
                     int             rowIndex      = 0;
                     DataGridViewRow row           = dataGridView1.Rows
                                                     .Cast <DataGridViewRow>()
                                                     .Where(r => r.Cells["Amount"].Value.ToString().Equals(MoneyValue))
                                                     .First();
                     rowIndex = row.Index;
                     dataGridView1["Amount", rowIndex].Value = MoneyValue;
                     dataGridView1["Count", rowIndex].Value  = MoneyQuantity;
                 }
             }
         }
     }
     catch
     {
     }
 }