Esempio n. 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(keyField.Value))//insert
        {
            KHACH_SAN obj = KHACH_SAN.Insert_Object(txtTenVanPhong.Text, txtDiaChi.Text, txtDienThoai.Text, ddlTinhThanh.SelectedValue);
            if (obj == null)
                HelpControls.ShowMsgBox(this, "Lưu dữ liệu thất bại!");
            else
            {
                InitListData();
                keyField.Value = obj.KHACH_SAN_ID;
                btnSave.Text = "Cập nhật";
            }

        }
        else
        {
            KHACH_SAN dd = new KHACH_SAN();
            dd.KHACH_SAN_ID = keyField.Value;
            if (dd.Save_Object(txtTenVanPhong.Text, txtDiaChi.Text,txtDienThoai.Text, ddlTinhThanh.SelectedValue))
            {
                InitListData();
            }
            else
            {
                HelpControls.ShowMsgBox(this, "Lưu dữ liệu thất bại!");
            }
        }
    }
Esempio n. 2
0
        //───────────────────────────────────────────────────────────────────────────────────────
        public static KHACH_SAN Insert_Object(
            string  sTEN_KHACH_SAN
            ,string  sDIA_CHI
            ,string  sSO_DIEN_THOAI
            ,string  sTINH_THANH
            )
        {
            string tem_sTEN_KHACH_SAN=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sTEN_KHACH_SAN,"nvarchar");
              string tem_sDIA_CHI=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sDIA_CHI,"nvarchar");
              string tem_sSO_DIEN_THOAI=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sSO_DIEN_THOAI,"varchar");
              string tem_sTINH_THANH=MinhTam.DataAccess.Web.SQLToolWeb.GetSaveValue(sTINH_THANH,"int");

             string sqlSave=" INSERT INTO KHACH_SAN("+
                   "TEN_KHACH_SAN,"
            +                   "DIA_CHI,"
            +                   "SO_DIEN_THOAI,"
            +                   "TINH_THANH) VALUES("
             +tem_sTEN_KHACH_SAN+","
             +tem_sDIA_CHI+","
             +tem_sSO_DIEN_THOAI+","
             +tem_sTINH_THANH +")";
             bool OK = Exec(sqlSave)>=1?true:false;
               if (OK)
               {
              KHACH_SAN newKHACH_SAN= new KHACH_SAN();
                 newKHACH_SAN.KHACH_SAN_ID=GetTable( " SELECT TOP 1 KHACH_SAN_ID FROM KHACH_SAN ORDER BY KHACH_SAN_ID DESC ").Rows[0][0].ToString();
              newKHACH_SAN.TEN_KHACH_SAN=sTEN_KHACH_SAN;
              newKHACH_SAN.DIA_CHI=sDIA_CHI;
              newKHACH_SAN.SO_DIEN_THOAI=sSO_DIEN_THOAI;
              newKHACH_SAN.TINH_THANH=sTINH_THANH;
            return newKHACH_SAN;
               }
               else return null ;
        }