using ABC.File;
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;



namespace ABC.GiaoDich
{
    public partial class CapNhatGia_Form : Form
    {
        public CapNhatGia_Form()
        {
            InitializeComponent();
            this.Text = "Bảng Giá Chung Ngày " + Get_CauHinh.ngay_text;
            load();
            gv.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gv_CellValueChanged);
        }

        void gv_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            
            if (Pow.kiemtra("CapNhatGia_Form", "Sua", Get_CauHinh.Dt_Login.Rows[0]["ID"].ToString().ToUpper()) == true)
            {
                #region
                DataRow dr = gv.GetDataRow(gv.FocusedRowHandle);
                string sql = "NhapSi_update_Gia_2 ";
//                    @ID_Hang uniqueidentifier,
                sql += "N'" + dr["ID_Hang"].ToString().ToUpper() + "',";
                
                    //@ID_NCC uniqueidentifier,
                sql += "N'" + dr["ID_NCC"].ToString().ToUpper() + "',";
                    //@Date_Num_Final_UpDate int,
                sql += "N'" + dr["Date_Num_Final_UpDate"].ToString() + "',";
                    //@Gia_2 decimal
                sql += "N'" + e.Value.ToString() + "'";
                _NhapSi_Class.set(sql);
                #endregion
            }
            else
            {
                gv.CancelUpdateCurrentRow();
            }
        }
        NhapSi_Class _NhapSi_Class = new NhapSi_Class();
        DataSet dt_main;
        public void load()
        {
            string sql = "select * from NhapSi_GiaChung where Date_Num_Final_UpDate = "+Get_CauHinh.Ngay_DN+"";
            dt_main = _NhapSi_Class.get_dataset(sql);
            gc.DataSource = dt_main.Tables[0];
            gv.ExpandAllGroups();

        }       
    }
}
