private T_Phathanh SetItem() { T_Phathanh _obj = new T_Phathanh(); if (Page.Request.Params["id"] != null) { _obj.Id = int.Parse(Page.Request["id"].ToString()); } else { _obj.Id = 0; } _obj.Ma_Anpham = Convert.ToInt32(this.ddl_AnPham.SelectedValue.ToString()); _obj.Ma_Sobao = Convert.ToInt32(this.ddl_Sobao.SelectedValue.ToString()); if (this.txt_NgayPhatHanh.Text.Length > 0) { _obj.Ngay_Phathanh = UltilFunc.ToDate(this.txt_NgayPhatHanh.Text, "dd/MM/yyyy"); } if (txt_SoluongPH.Text.Length > 0) { _obj.Soluong_PH = Convert.ToInt32(this.txt_SoluongPH.Text.Trim()); } if (txt_SoluongTon.Text.Length > 0) { _obj.Soluong_ton = Convert.ToInt32(this.txt_SoluongTon.Text.Trim()); } _obj.Ghichu = this.txt_Ghichu.Text.Trim(); return(_obj); }
public int InsertT_Phathanh(T_Phathanh _Obj) { try { return(HPCDataProvider.Instance().InsertObjectReturn(_Obj, "[Sp_InsertT_Phathanh]")); } catch (Exception ex) { throw ex; } }
protected void Save_Click(object sender, EventArgs e) { #region GhiLog Lichsu_Thaotac_HethongDAL actionDAL = new Lichsu_Thaotac_HethongDAL(); T_Lichsu_Thaotac_Hethong action = new T_Lichsu_Thaotac_Hethong(); action.Ma_Nguoidung = _user.UserID; action.TenDaydu = _user.UserFullName; action.HostIP = IpAddress(); action.NgayThaotac = DateTime.Now; #endregion this.Page.Validate(vs_Themmoi.ValidationGroup); if (!Page.IsValid) { return; } PhathanhDAL _phathanhDAL = new PhathanhDAL(); T_Phathanh _phathanh = SetItem(); int menuID = 0; if (Request["ID"] != null && Request["ID"].ToString() != "" && Request["ID"].ToString() != String.Empty) { menuID = int.Parse(Request["ID"].ToString()); } int _return = _phathanhDAL.InsertT_Phathanh(_phathanh); if (Page.Request.Params["id"] == null) { action.Thaotac = "[Thêm mới T_PhatHanh]-->[Mã:" + _return.ToString() + " ]"; System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + Global.RM.GetString("VALIDATE_ADDNEWS") + "');", true); actionDAL.InserT_Lichsu_Thaotac_Hethong(action); Clear(); BindCombo(); return; } if (Page.Request.Params["id"] != null) { action.Thaotac = "[Sửa T_PhatHanh]-->[Mã :" + Page.Request["id"].ToString() + " ]"; System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + Global.RM.GetString("UpdateSuccessfully") + "');", true); actionDAL.InserT_Lichsu_Thaotac_Hethong(action); Clear(); BindCombo(); return; } }
private void GetItem(int _id) { T_Phathanh _obj = new T_Phathanh(); PhathanhDAL _objDAL = new PhathanhDAL(); _obj = _objDAL.GetOneFromT_PhathanhByID(_id); this.ddl_AnPham.SelectedIndex = UltilFunc.GetIndexControl(ddl_AnPham, _obj.Ma_Anpham.ToString()); if (_id > 0) { this.ddl_Sobao.Items.Clear(); UltilFunc.BindCombox(ddl_Sobao, "Ma_Sobao", "Ten_Sobao", "T_Sobao", " Ma_AnPham = " + _obj.Ma_Anpham.ToString()); this.ddl_Sobao.SelectedIndex = UltilFunc.GetIndexControl(ddl_Sobao, _obj.Ma_Sobao.ToString()); this.txt_NgayPhatHanh.Text = _obj.Ngay_Phathanh.ToString("dd/MM/yyyy"); } this.txt_SoluongPH.Text = _obj.Soluong_PH.ToString(); this.txt_SoluongTon.Text = _obj.Soluong_ton.ToString(); this.txt_Ghichu.Text = _obj.Ghichu; }