protected void m_grv_don_hang_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            switch (e.CommandName)
            {
                case "Detail":
                    if (e.CommandArgument.Equals("")) return;
                    decimal v_dc_id_don_hang = CIPConvert.ToDecimal(e.CommandArgument);
                    m_hdf_id_don_hang_detail.Value = CIPConvert.ToDecimal(e.CommandArgument).ToString();
                    US_GD_DON_DAT_HANG v_us = new US_GD_DON_DAT_HANG();
                    DS_GD_DON_DAT_HANG v_ds = new DS_GD_DON_DAT_HANG();
                    v_us.FillDataset(v_ds, "where id=" + v_dc_id_don_hang);
                    string v_str_ma_hd = v_ds.Tables[0].Rows[0]["MA"].ToString();
                    m_lbl_pop_tong_tien.Text = CIPConvert.ToStr(v_ds.Tables[0].Rows[0]["GIA_TRI_DA_VAT"], "#,###") + "  (VNĐ)";
                    m_lbl_ten_detail.Text = "Chi tiết mã phiếu :" + v_str_ma_hd;
                    load_data_2_grid_detail(v_dc_id_don_hang);
                    break;

            }
        }
        catch (Exception v_e)
        {
            CSystemLog_301.ExceptionHandle(this, v_e);
        }
    }
Ejemplo n.º 2
0
    private void load_ma_don_hang_title()
    {
        US_GD_DON_DAT_HANG v_us = new US_GD_DON_DAT_HANG();
        DS_GD_DON_DAT_HANG v_ds = new DS_GD_DON_DAT_HANG();
        v_us.FillDataset(v_ds, "where id=" + CIPConvert.ToDecimal(m_hdf_id_don_hang.Value));
        m_lbl_title_ma_don_hang.Text = "Nhập chi tiết đơn hàng ";
        m_lbl_ma_don_hang_de.Text = v_ds.Tables[0].Rows[0]["MA"].ToString();
        m_lbl_ma_don_hang_de.Visible = true;
        m_lbl_MP.Visible = true;

        decimal v_id_phong_ban = CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value);
        US_RPT_GD_DON_DAT_HANG_DINH_MUC v_us_don_hang = new US_RPT_GD_DON_DAT_HANG_DINH_MUC();
        DS_RPT_GD_DON_DAT_HANG_DINH_MUC v_ds_don_hang = new DS_RPT_GD_DON_DAT_HANG_DINH_MUC();
        v_us_don_hang.FillDS_don_hang_dinh_muc(v_ds_don_hang, v_id_phong_ban);
        m_lbl_pop_lan.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["LAN"], "#,###");
        DateTime v_dat_ngay = (DateTime)v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["NGAY_DAT_HANG"];
        m_lbl_pop_ngay.Text = v_dat_ngay.ToString("dd/MM/yyyy");
        m_lbl_pop_tong_tien.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"], "#,###") + "  (VNĐ)";
        m_lbl_pop_dinh_muc.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"], "#,###") + "  (VNĐ)";
    }
 private void load_ma_don_hang_nhap_gan_nhat()
 {
     US_GD_DON_DAT_HANG v_us = new US_GD_DON_DAT_HANG();
     DS_GD_DON_DAT_HANG v_ds = new DS_GD_DON_DAT_HANG();
     v_us.FillDataset(v_ds, "SELECT TOP(1) * FROM GD_DON_DAT_HANG WHERE ID_TRANG_THAI= " + CONST_ID_TRANG_THAI_DON_HANG.NHAP + " ORDER BY NGAY_DAT_HANG DESC, LAN DESC");
     if (v_ds.Tables[0].Rows.Count != 0)
     {
         m_hdf_id_don_hang.Value = v_ds.Tables[0].Rows[0]["ID"].ToString();
         load_ma_don_hang_title();
         load_data_to_grid_don_hang_de();
     }
     else return;
 }
    private void load_ma_don_hang_title()
    {
        US_GD_DON_DAT_HANG v_us = new US_GD_DON_DAT_HANG();
        DS_GD_DON_DAT_HANG v_ds = new DS_GD_DON_DAT_HANG();
        US_V_GD_DE_XUAT v_us_de_xuat = new US_V_GD_DE_XUAT();
        DS_V_GD_DE_XUAT v_ds_de_xuat = new DS_V_GD_DE_XUAT();
        update_tong_tien_don_hang(CIPConvert.ToDecimal(m_hdf_id_don_hang.Value));
        v_us.FillDataset(v_ds, "where id=" + CIPConvert.ToDecimal(m_hdf_id_don_hang.Value));
        m_lbl_title_ma_don_hang.Text = "Nhập chi tiết đơn hàng ";
        m_lbl_ma_don_hang_de.Text = v_ds.Tables[0].Rows[0]["MA"].ToString();
        m_lbl_ma_don_hang_de.Visible = true;
        m_lbl_MP.Visible = true;

        decimal v_id_phong_ban = CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value);
        decimal v_ti_le_vuot;
        decimal tien_de_xuat;
        decimal tong_tien;
        decimal dinh_muc;
        US_RPT_GD_DON_DAT_HANG_DINH_MUC v_us_don_hang = new US_RPT_GD_DON_DAT_HANG_DINH_MUC();
        DS_RPT_GD_DON_DAT_HANG_DINH_MUC v_ds_don_hang = new DS_RPT_GD_DON_DAT_HANG_DINH_MUC();
        v_us_don_hang.FillDS_don_hang_dinh_muc(v_ds_don_hang, v_id_phong_ban);
        m_lbl_pop_lan.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["LAN"],"#,###");
        DateTime v_dat_ngay = (DateTime)v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["NGAY_DAT_HANG"];
        m_lbl_pop_ngay.Text = v_dat_ngay.ToString("dd/MM/yyyy");
        m_lbl_pop_tong_tien.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"],"#,###") + "  (VNĐ)";
        m_lbl_pop_dinh_muc.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"], "#,###") + "  (VNĐ)";
        // tính tỉ lệ vượt
        v_us_de_xuat.FillDSLayDeXuat(v_ds_de_xuat, v_dat_ngay, v_id_phong_ban);
        if(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"] != "" || v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"] != null)
            tong_tien = CIPConvert.ToDecimal(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"]);
        else tong_tien = 0;
        if(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"] != "" || v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"] != null)
            dinh_muc = CIPConvert.ToDecimal(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"]);
        else dinh_muc = 0;
        if(dinh_muc > 0)
        {
                if (v_ds_de_xuat.Tables[0].Rows.Count > 0)
                {
                    tien_de_xuat = CIPConvert.ToDecimal(v_ds_de_xuat.Tables[0].Rows[0]["SO_TIEN"]);

                     v_ti_le_vuot = ((tong_tien - tien_de_xuat - dinh_muc) / dinh_muc)*100;
                    if (v_ti_le_vuot > 0)
                     m_lbl_pop_ti_le_vuot.Text = CIPConvert.ToStr(v_ti_le_vuot,".#") + " (%)";
                    else m_lbl_pop_ti_le_vuot.Text = "0 (%)";
                }
                else
                {
                    v_ti_le_vuot = ((tong_tien - dinh_muc) / dinh_muc)*100;
                    if(v_ti_le_vuot > 0)
                        m_lbl_pop_ti_le_vuot.Text = CIPConvert.ToStr(v_ti_le_vuot, ".#") + " (%)";
                    else m_lbl_pop_ti_le_vuot.Text = "0 (%)";
                }
        }
        else m_lbl_pop_ti_le_vuot.Text = "Chưa có định mức";
    }
 private void tao_don_hang()
 {
     DateTime v_ngay_dau_thang = DateTime.Now.AddDays(-DateTime.Now.Day + 1);
     m_txt_ngay_nhap.Text = DateTime.Now.Date.ToString("dd/MM/yyyy");
     m_lbl_hien_thi_so_phieu.Text = CIPConvert.ToStr(m_hdf_ma_trung_tam.Value) + "-" + DateTime.Now.ToString("yyyyMMdd");
     US_GD_DON_DAT_HANG v_us = new US_GD_DON_DAT_HANG();
     DS_GD_DON_DAT_HANG v_ds = new DS_GD_DON_DAT_HANG();
     v_us.get_so_don_hang_nhap_trung_tam(v_ds, CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value), CONST_ID_TRANG_THAI_DON_HANG.NHAP);
     if (v_ds.GD_DON_DAT_HANG.Rows.Count > 0)
     {
         m_lbl_hien_thi_so_phieu.Text = v_ds.GD_DON_DAT_HANG.Rows[0]["MA"].ToString();
         m_txt_so_lan.Text = v_ds.GD_DON_DAT_HANG.Rows[0]["LAN"].ToString();
         DateTime v_ngay_dat_hang = (DateTime)v_ds.GD_DON_DAT_HANG.Rows[0]["NGAY_DAT_HANG"];
         m_txt_ngay_nhap.Text = v_ngay_dat_hang.ToString("dd/MM/yyyy");
     }
     else
     {
         v_us.FillDataset(v_ds, v_ngay_dau_thang, CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value));
         m_us_gd_don_dat_hang = new US_GD_DON_DAT_HANG();
         m_us_gd_don_dat_hang.dcID_PHONG_BAN = CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value);
         if (v_ds.GD_DON_DAT_HANG.Rows.Count > 0)
         {
             m_us_gd_don_dat_hang.dcLAN = v_ds.GD_DON_DAT_HANG.Rows.Count + 1;
             m_txt_so_lan.Text = m_us_gd_don_dat_hang.dcLAN.ToString();
         }
         else
         {
             m_us_gd_don_dat_hang.dcLAN = 1;
             m_txt_so_lan.Text = "1";
         }
         m_us_gd_don_dat_hang.dcID_TRANG_THAI = CONST_ID_TRANG_THAI_DON_HANG.NHAP;
         m_us_gd_don_dat_hang.datNGAY_DAT_HANG = DateTime.Now.Date;
         m_us_gd_don_dat_hang.strMA = m_lbl_hien_thi_so_phieu.Text;
         m_us_gd_don_dat_hang.strMA_HD_NCC = "";
         m_us_gd_don_dat_hang.dcGIA_TRI_DA_VAT = 0;
         m_us_gd_don_dat_hang.dcGIA_TRI_CHUA_VAT = 0;
         m_us_gd_don_dat_hang.Insert();
     }
     m_hdf_ngay_dat_hang.Value = m_txt_ngay_nhap.Text;
 }