using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ABC.GiaoDich;
using ABC.Report;
using ABC.KetNoi;
using DevExpress.XtraGrid.Columns;
using DevExpress.Data.Filtering;
using ABC.BaoCao;
using DevExpress.XtraSplashScreen;
using DevExpress.XtraReports.UI;
using DevExpress.XtraGrid.Views.Base;
using ABC.File;

namespace ABC.CongNo
{
    public partial class frmVuot_DM_CongNo_SoThuTien : DevExpress.XtraEditors.XtraForm
    {

        public frmVuot_DM_CongNo_SoThuTien(DataTable _dt)
        {
            InitializeComponent();
            Get_CauHinh.NgayTinhNo = Get_CauHinh.Ngay_DN;
           
            event_click();
            dtKH = DuLieu.List_KhachHang.Tables[0];
           // Look_khachhang.Properties.DataSource = dtKH;
            
            gv_daluu.CellValueChanged+=new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gv_daluu_CellValueChanged);
            gv_daluu.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(gv_daluu_RowCellClick);
           // txtngay.Text = Get_CauHinh.ngay_text;
            dtGrid = _dt;
            this.Load += new EventHandler(CongNo_SoThuTien_Load);
            //khai bai report truoc
           
        }
        DataTable dtGrid;
        DataTable dtKH;
        void CongNo_SoThuTien_Load(object sender, EventArgs e)
        {
            
            tailai();

            
        }

        void gv_daluu_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            #region
            string col = e.Column.Caption;
            string colname = e.Column.FieldName;
            if (colname == "NoCu")
            {
                 kh_ten_choos = gv_daluu.GetDataRow(gv_daluu.FocusedRowHandle)["Tbl_KhachHang_Name"].ToString();
                 kh_id_choos = gv_daluu.GetDataRow(gv_daluu.FocusedRowHandle)["ID_KhachHang"].ToString();
               // ngay =int.Parse(gv_daluu.GetDataRow(gv_daluu.FocusedRowHandle)["NgayPhatSinhNo"].ToString());                
                xemnocu();
            }            
            if (colname == "NoMoi")
            {
                 kh_ten_choos = gv_daluu.GetDataRow(gv_daluu.FocusedRowHandle)["Tbl_KhachHang_Name"].ToString();
                 kh_id_choos = gv_daluu.GetDataRow(gv_daluu.FocusedRowHandle)["ID_KhachHang"].ToString();
               //  ngay = int.Parse(gv_daluu.GetDataRow(gv_daluu.FocusedRowHandle)["NgayPhatSinhNo"].ToString());                
                xemnomoi();
            }
            #endregion
        }
        string kh_ten_choos = "";
        string kh_id_choos = "";        
#pragma warning disable CS0414 // The field 'frmVuot_DM_CongNo_SoThuTien.ngay' is assigned but its value is never used
        int ngay = 0;
#pragma warning restore CS0414 // The field 'frmVuot_DM_CongNo_SoThuTien.ngay' is assigned but its value is never used
        public void xemnomoi()
        {
            //ngay = (int)(Convert.ToDateTime(txtngay.Text) - new DateTime(1900, 1, 1)).TotalDays;

            //BaoCao_SoBanHang_ChiTiet_KH ct = new BaoCao_SoBanHang_ChiTiet_KH();
            //ct.xemtuformcongno = true;
            //ct.hinhthucxem = "NoMoi";
            //ct.ngayxemcongno = txtngay.Value;
            //ct.kh_ten_congno = kh_ten_choos;
            //ct.kh_id_congno = kh_id_choos; ;            
            //ct.ShowDialog();
        }
      
        public void xemnocu()
        {
            #region
            //BaoCao_SoBanHang_ChiTiet_KH ct = new BaoCao_SoBanHang_ChiTiet_KH();
            //ct.xemtuformcongno = true;
            //ngay = (int)(Convert.ToDateTime(txtngay.Text) - new DateTime(1900, 1, 1)).TotalDays;            
            //ct.ngayxemcongno = new DateTime(1900, 1, 1).AddDays(ngay-1);
            //ct.hinhthucxem = "NoCu";
            //// get ngay TRA
            //string sql = "SELECT ID_KhachHang,MAX(NgayPhatSinhNo) as NGAYTRASAUCUNG FROM TongTra_Cua_moi_Ngay WHERE ID_KhachHang ='" + kh_id_choos + "' AND NgayPhatSinhNo <" + ngay + " GROUP BY ID_KhachHang";
            //DataTable DT_NGAYTRA = db.T_open(sql).Tables[0];
            //if (DT_NGAYTRA.Rows.Count > 0)
            //{
            //    #region kh co ngay tra 
            //    int ngay_tra =int.Parse(DT_NGAYTRA.Rows[0]["NGAYTRASAUCUNG"].ToString());
            //    ct.ngaytrasaucung = new DateTime(1900, 1, 1).AddDays(ngay_tra);
            //    ct.kh_ten_congno = kh_ten_choos;
            //    ct.kh_id_congno = kh_id_choos; ;
            //    ct.ShowDialog();
            //    #endregion
            //}
            //else
            //{
            //    #region kh khong co ngay tra
            //    //lay ngay mua dau tien
            //    ct.ngaytrasaucung = new DateTime(1900, 1, 1);
            //    ct.kh_ten_congno = kh_ten_choos;
            //    ct.kh_id_congno = kh_id_choos; ;
            //    ct.ShowDialog();
            //    #endregion
            //}
            #endregion
        }
      
        #region gv_daluu
        void gv_daluu_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                if (Pow.kiemtra("CongNo_SoThuTien", "Sua", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
                {
                    DataRow dt_update = gv_daluu.GetDataRow(gv_daluu.FocusedRowHandle);
                    decimal Tong_No = decimal.Parse(dt_update["TongNo"].ToString());
                    decimal TogTra = decimal.Parse(e.Value.ToString());
                    TogTra = TogTra * 1000;
                    if (TogTra > Tong_No)
                    {
                        msgbox.dialog_OK_warning("Tiền trả vược mức tiền nợ.");
                        gv_daluu.CancelUpdateCurrentRow();
                    }
                    else
                    {
                        #region

                        // xoa chi tiet
                        DataRow[] dtv = DuLieu.ChiTiet_TraNo.Tables[0].Select("ID_KhachHang = '" + dt_update["ID_KhachHang"].ToString().ToUpper() + "' and SuDung = 1 and NgayPhatSinhNo = " + Get_CauHinh.NgayTinhNo + "");
                        //dtv.RowFilter = "ID_KhachHang = '" + dt_update["ID_KhachHang"].ToString().ToUpper() + "' and SuDung = 1 and NgayPhatSinhNo = " + Get_CauHinh.NgayTinhNo + "";
                        int i = 0;
                        for (i = 0; i < dtv.Length; i++)
                        {
                            string sql1 = "Tbl_ChiTietTraNo_XoaChiTiet ";
                            sql1 += "N'" + dtv[i]["ID_KhachHang"].ToString().ToUpper() + "',";
                            sql1 += "N'" + dtv[i]["Luc"].ToString() + "',";
                            sql1 += "N'" + dtv[i]["NgayPhatSinhNo"].ToString() + "'";
                            db.T_exc(sql1);
                        }
                        if (i == dtv.Length)
                        {
                            // them chi tiet moi
                            string sql = "Tbl_ChiTietTraNo_insert ";
                            //@ID_KhachHang uniqueidentifier,
                            sql += "N'" + dt_update["ID_KhachHang"].ToString().ToUpper() + "',";
                            //@Luc nvarchar(200),
                            sql += "N'" + DateTime.Now.Hour.ToString() + " giờ " + DateTime.Now.Minute.ToString() + " phút " + DateTime.Now.Second.ToString() + " giây " + DateTime.Now.Date.ToShortDateString() + "',";
                            //@NgayPhatSinhNo int,
                            //if (check_ngay.Checked == false)
                            //{
                            //    sql += "N'" + Get_CauHinh.NgayTinhNo + "',";
                            //}
                            //else
                            //{
                            //    int ng = (int)(Convert.ToDateTime(txtngay.Text) - new DateTime(1900, 1, 1)).TotalDays;
                            //    sql += "N'" + ng + "',";
                            //}
                            //@Tien decimal
                            sql += "N'" + TogTra + "'";
                            db.T_exc(sql);
                        }
                        //
                        //tailai();
                        //DataRow[] dt_r = DuLieu.CongNo_1Ngay.Tables[0].Select("ID_KhachHang = '" + dt_update["ID_KhachHang"].ToString().ToUpper());
                        DuLieu.CongNo_1Ngay.Tables[0].AcceptChanges();
                        //gv_daluu.RefreshData();

                        #region
                        string sql_tinhlai = "sp_ChiTietTraNo_TrongNgay " + Get_CauHinh.NgayTinhNo + ",'" + dt_update["ID_KhachHang"].ToString().ToUpper() + "'";
                        DataSet dts = db.T_opendataset(sql_tinhlai);
                        if (dts.Tables[0].Rows.Count > 0)
                        {
                            double tongtra_laytu_sql;
                            try
                            {
                                tongtra_laytu_sql = double.Parse(dts.Tables[0].Rows[0]["tongtra"].ToString());
                            }
                            catch
                            {
                                tongtra_laytu_sql = 0;
                            }

                            if (tongtra_laytu_sql != 0)
                            {
                                // DataRow[] dr = DuLieu.CongNo_1Ngay.Tables[0].Select();
                                DataRow[] dt_r = DuLieu.CongNo_1Ngay.Tables[0].Select("ID_KhachHang = '" + dt_update["ID_KhachHang"].ToString().ToUpper() + "'");
                                double nommoi = double.Parse(dt_r[0]["NoMoi"].ToString());
                                double nocu = double.Parse(dt_r[0]["NoCu"].ToString());

                                double ton = (nommoi + nocu) - tongtra_laytu_sql;
                                dt_r[0]["Ton"] = ton;
                                dt_r[0]["MoiTra"] = tongtra_laytu_sql;
                                dt_r[0]["GhiChu"] = "";
                                DuLieu.CongNo_1Ngay.Tables[0].AcceptChanges();


                            }
                        }
                        #endregion
                        data();
                        #endregion
                    }
                }
                else
                {
                    gv_daluu.CancelUpdateCurrentRow();
                }
            }
            catch (Exception)
            {
              
            }
            

        }
        #endregion

        #region lệnh dùng chung
        public void excel()
        {
        }
       

        #region cap nhat tien tra
        TienTra _TienTra;
        public void btn_capnhat()
        {
            if (Pow.kiemtra("CongNo_SoThuTien", "Sua", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            {
                _TienTra = new TienTra();
               
                _TienTra.FormClosed += new FormClosedEventHandler(_TienTra_FormClosed);
                _TienTra.TextChanged += new EventHandler(_TienTra_TextChanged);
                _TienTra.ShowDialog();
            }
            
        }
        string select_khachhang_name;
        
        void _TienTra_TextChanged(object sender, EventArgs e)
        {
            select_khachhang_name = _TienTra.select_khachhang_name;
           // msgbox.dialog_OK_info(select_khachhang_name);
           // gv_daluu.Columns["gridColumn1"].FilterInfo = new ColumnFilterInfo("[gridColumn1] LIKE '" + select_khachhang_name + "'");
           gv_daluu.ActiveFilterString = "[Tbl_KhachHang_Name] = '" + select_khachhang_name + "'";

      

            
        }

        void _TienTra_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (_TienTra.DialogResult == DialogResult.OK)
            {

                data();

               
            }
            gv_daluu.ClearColumnsFilter();
            //CriteriaOperator expr0 = null;
            //gv_daluu.ActiveFilterCriteria = GroupOperator.And(new CriteriaOperator[] { expr0 });
            //_TienTra = new TienTra();
        }
#endregion

        #region
        public void khaibao_nodau()
        {
            if (Pow.kiemtra("CongNo_SoThuTien", "Sua", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            {
                #region
                _T_KhaiBaoCongNo = new T_KhaiBaoCongNo();
                _T_KhaiBaoCongNo.FormClosed += new FormClosedEventHandler(_T_KhaiBaoCongNo_FormClosed);
                _T_KhaiBaoCongNo.ShowDialog();
                #endregion
            }
            else
            {
                msgbox.dialog_OK_warning("Bạn không có quyền cập nhật");
            }
        }
        T_KhaiBaoCongNo _T_KhaiBaoCongNo;
        void _T_KhaiBaoCongNo_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (_T_KhaiBaoCongNo.DialogResult == DialogResult.OK)
            {
                tailai();
            }
        }
        #endregion

        public void sua()
        {
            if (Pow.kiemtra("CongNo_SoThuTien", "Sua", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            {
               
            }
        }

        
        public void print1()
        {
            if (Pow.kiemtra("CongNo_SoThuTien", "Inan", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            {
               
                T_Tien1 rapport = new T_Tien1();
                rapport.DataSource = dtGrid;              
                rapport.ShowPreview();
            }
        }
        public void print2()
        {
            //if (Pow.kiemtra("CongNo_SoThuTien", "Inan", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            //{
            //    Get_CauHinh.sono1 = "Ngày " + txtngay.Value.Day.ToString() + " Tháng " + txtngay.Value.Month.ToString() + " Năm " + txtngay.Value.Year.ToString();
            //    // Remember_ID_combo_selected.tongno = "Tổng Tiền Nợ : " + String.Format("{0:N0}", tongcong);
            //    T_Tien rapport = new T_Tien();

            //    rapport.DataSource = DuLieu.CongNo_1Ngay;
               
            //    rapport.ShowPreview();
            //}
        }
        Class_KetNoi db = new Class_KetNoi();
#pragma warning disable CS0169 // The field 'frmVuot_DM_CongNo_SoThuTien.ngaydetru' is never used
        int ngaydetru;
#pragma warning restore CS0169 // The field 'frmVuot_DM_CongNo_SoThuTien.ngaydetru' is never used
        public void tailai()
        {
           
         //   string filter_string = "";          
            
         //   if (check_ngay.Checked == true)
         //   {
         //       int ng = (int)(Convert.ToDateTime(txtngay.Text) - new DateTime(1900, 1, 1)).TotalDays;
         //       ngaydetru = ng;
               
         //       Get_CauHinh.NgayTinhNo = ng;
         //       Get_CauHinh.NgayTinhNo_text = txtngay.Text;
                
                

         //       filter_string = "XemNo_1Ngay " + ng + ",";
         //       //filter_string = "XemNo_1Ngay "+ng+",Null,Null,Null";
         //       if (checksongay.Checked == true && txtsongay.Text != null && txtsongay.Text!="")
         //       {
         //           filter_string += txtsongay.Text+",";
                    
         //       }
         //       else
         //       {
         //           filter_string += "Null,";
         //       }
         //       //------
         //       if (check_kytu.Checked == true && txtkhachhang.Text != null && txtkhachhang.Text != "")
         //       {
         //           filter_string += "'"+txtkhachhang.Text+"',";
         //       }
         //       else
         //       {
         //           filter_string += "Null,";
         //       }

         //       if (check_ten.Checked == true && Look_khachhang.EditValue != null && Look_khachhang.EditValue!="")
         //       {
         //           filter_string += "'" + Look_khachhang.EditValue.ToString().ToUpper() + "'";
         //       }
         //       else
         //       {
         //           filter_string += "Null";
         //       }
                
         //   }
         //   else
         //   {
         //       Get_CauHinh.NgayTinhNo = Get_CauHinh.Ngay_DN;
         //       Get_CauHinh.NgayTinhNo_text = Get_CauHinh.ngay_text;
         //       ngaydetru = Get_CauHinh.Ngay_DN;
                

         //       filter_string = "XemNo_1Ngay " + Get_CauHinh.NgayTinhNo + ",";
         //       if (checksongay.Checked == true && txtsongay.Text != null && txtsongay.Text != "")
         //       {
         //           filter_string += "'"+txtsongay.Text+"',";
         //       }
         //       else
         //       {
         //           filter_string += "Null,";
         //       }
         //       //------
         //       if (check_kytu.Checked == true && txtkhachhang.Text != null && txtkhachhang.Text != "")
         //       {
         //           filter_string += "'" + txtkhachhang.Text + "',";
         //       }
         //       else
         //       {
         //           filter_string += "Null,";
         //       }

         //       if (check_ten.Checked == true && Look_khachhang.EditValue != null && Look_khachhang.EditValue != "")
         //       {
         //           filter_string += "'" + Look_khachhang.EditValue.ToString().ToUpper() + "'";
         //       }
         //       else
         //       {
         //           filter_string += "Null";
         //       }
         //   }

         //   DuLieu.CongNo_1Ngay = db.T_open(filter_string);
         ////   DuLieu.CongNo_1Ngay.Tables[0].Columns.Add("VuotHanMuc");
         //   DuLieu.CongNo_1Ngay.Tables.Remove("Table");
           
           data();
          
        }
       
#pragma warning disable CS0169 // The field 'frmVuot_DM_CongNo_SoThuTien.dts' is never used
        DataSet dts;
#pragma warning restore CS0169 // The field 'frmVuot_DM_CongNo_SoThuTien.dts' is never used
        public void print1111()
        {
           
            //if (Pow.kiemtra("CongNo_SoThuTien", "Inan", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            //{
            //    #region
            //    DataSet dsSelectData = new DataSet();

            //    dsSelectData = DuLieu.BaoCao_SoBaoCao_Si_Bien;
            //    Get_CauHinh.report_ngay = "BÁO CÁO NHẬP SĨ (BIỂN) NGÀY " + txtngay.Value.ToShortDateString();
            //    T_BaocaonhapsiBien rapport = new T_BaocaonhapsiBien();
            //    rapport.DataSource = dsSelectData;
            //    rapport.LocationFloat = new DevExpress.Utils.PointFloat(10, 10);
            //    rapport.ShowPreview();

            //    #endregion
            //}
        }
        public void print_bill()
        {
            //if (Pow.kiemtra("CongNo_SoThuTien", "Inan", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            //{
            //    #region
            //    Get_CauHinh.bill_no = "Ngày " + txtngay.Value.Day.ToString() + " Tháng " + txtngay.Value.Month.ToString() + " Năm " + txtngay.Value.Year.ToString();
            //   // Remember_ID_combo_selected.tongno = "Tổng Tiền Nợ : " + String.Format("{0:N0}", tongcong);
            //    //get cong no ket
            //    tailai_ket();
            //    //tai lai sot
            //    tailai_sot();
            //    T_bill_tien rapport = new T_bill_tien();
            //    try { DuLieu.CongNo_1Ngay.Tables[0].Columns.Add("TonS", typeof(int)); DuLieu.CongNo_1Ngay.Tables[0].Columns.Add("TonK", typeof(int)); }
            //    catch { };
            //    for (int i = 0; i < DuLieu.CongNo_1Ngay.Tables[0].Rows.Count; i++)
            //    {
            //        DataRow dr_no = DuLieu.CongNo_1Ngay.Tables[0].Rows[i];
            //        DataRow[] dr_sot = DuLieu.CongNo_1Ngay_Sot.Tables[0].Select("ID_KhachHang = '" + DuLieu.CongNo_1Ngay.Tables[0].Rows[i]["ID_KhachHang"].ToString().ToUpper() + "'");
            //        DataRow[] dr_ket = DuLieu.CongNo_1Ngay_Ket.Tables[0].Select("ID_KhachHang = '" + DuLieu.CongNo_1Ngay.Tables[0].Rows[i]["ID_KhachHang"].ToString().ToUpper() + "'");
            //        if (dr_sot.Length > 0)
            //        {
            //            dr_no["TonS"] = dr_sot[0]["Ton"];
            //        }
            //        else
            //        {
            //            dr_no["TonS"] = 0;
            //        }
            //        if (dr_ket.Length > 0)
            //        {
            //            dr_no["TonK"] = dr_ket[0]["Ton"];
            //        }
            //        else
            //        {
            //            dr_no["TonK"] = 0;
            //        }
            //        DuLieu.CongNo_1Ngay.Tables[0].AcceptChanges();
            //    }
            //        rapport.DataSource = DuLieu.CongNo_1Ngay;
               
            //    rapport.ShowPreview();
            //    #endregion
            //}
        }
        #endregion

        #region tailai ket
        public void tailai_ket()
        {

           

            data();

        }
        #endregion

        #region tai lai sot
        public void tailai_sot()
        {

            

            data();

        }
        #endregion

        #region menu click
        public void event_click()
        {
           
           // btn_tratien.Click += new EventHandler(btn_del_Click);          
            btn_print1.Click += new EventHandler(btn_all_Click);
            //btn_print2.Click += new EventHandler(btn_none_Click);
            btn_close.Click += new EventHandler(btn_close_Click);
           // btn_load.Click += new EventHandler(btn_load_Click);
           // btn_nodau.Click += new EventHandler(btn_in_Click);
           // btn_bill.Click += new EventHandler(btn_sua_Click);
           
        }

        void btn_ghichu_Click(object sender, EventArgs e)
        {
            xemghichu();
            data();
        }
        public void xemghichu()
        {
           
        }

        void btn_sua_Click(object sender, EventArgs e)
        {
            print_bill();
        }

   

        void btn_in_Click(object sender, EventArgs e)
        {
            khaibao_nodau();
        }

        void btn_load_Click(object sender, EventArgs e)
        {
            
            tailai();

            
        }

        void btn_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        void btn_none_Click(object sender, EventArgs e)
        {
            print2();
        }

        void btn_all_Click(object sender, EventArgs e)
        {
            print1();
        } 

        void btn_del_Click(object sender, EventArgs e)
        {
            btn_capnhat();
        }

       


        #endregion

        #region data       
#pragma warning disable CS0169 // The field 'frmVuot_DM_CongNo_SoThuTien.dtv_songay' is never used
        DataView dtv_songay;
#pragma warning restore CS0169 // The field 'frmVuot_DM_CongNo_SoThuTien.dtv_songay' is never used
        public void data()
        {
           
            gv_daluu.ClearColumnsFilter();
                gc_daluu.DataSource =dtGrid;
                gv_daluu.ExpandAllGroups();
                gv_daluu.ExpandAllGroups();
                gv_daluu.RefreshData();

            lbnocu.Text = cnocu.SummaryText + " (vnđ)";
            lbnomoi.Text = cnomoi.SummaryText + " (vnđ)";
            lbtongno.Text = ctongno.SummaryText + " (vnđ)";
            lbtongtra.Text = ctongtra.SummaryText + " (vnđ)";
            lbton.Text = cton.SummaryText + " (vnđ)";
        }
        #endregion

        private void BaoCao_ToaSi_Load(object sender, EventArgs e)
        {
            
            data();
        }

        private void gv_daluu_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            //try
            //{
            //    string _vuot = gv_daluu.GetRowCellValue(e.RowHandle, "VuotHanMuc").ToString().Trim();
            //    if (_vuot == "x")
            //    {
            //        e.Appearance.BackColor = Color.Red;
            //        e.Appearance.ForeColor = Color.White;
            //    }
            //}
            //catch (Exception)
            //{
                
                
            //}
        }

        private void gv_daluu_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            try
            {
                double _hanmuc = double.Parse(gv_daluu.GetRowCellValue(e.RowHandle, "HanMuc").ToString().Trim());
                double _ton = double.Parse(gv_daluu.GetRowCellValue(e.RowHandle, "Ton").ToString().Trim());
                if (_hanmuc < _ton&&_hanmuc>0)
                {
                    e.Appearance.BackColor = Color.White;
                    e.Appearance.ForeColor = Color.Black;
                    //gv_daluu.SetRowCellValue(e.RowHandle, "VuotHanMuc", "x");
                }
            }
            catch (Exception)
            {
                
               
            }
          
        }

       

     

    }
}
