public static DataTable ParseToDataTable(IList<Data.PemeriksaanDetail> srs) { DataTable deta = new DataTable(); foreach (PropertyInfo info in typeof(Data.PemeriksaanDetail).GetProperties()) { deta.Columns.Add(info.Name, info.PropertyType); } deta.AcceptChanges(); foreach (var i in srs) { Data.PemeriksaanDetail sr = new Data.PemeriksaanDetail(); sr = i; DataRow row = deta.NewRow(); foreach (var property in sr.GetType().GetProperties()) { row[property.Name] = property.GetValue(sr, null); } deta.Rows.Add(row); } deta.AcceptChanges(); return deta; }
public static string SP_FindPemeriksaanById(string id, out Data.Pemeriksaan p) { p = null; SqlConnection sqlConn = new SqlConnection(); SqlCommand sqlCmd = new SqlCommand(); SqlDataAdapter sqlAdap = new SqlDataAdapter(); try { sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings["AMS_StockConnectionString"].ToString(); sqlConn.Open(); sqlCmd.CommandText = "SP_FindPemeriksaanById"; sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Connection = sqlConn; SqlParameter parm1 = new SqlParameter("@Id", SqlDbType.Int); parm1.Value = int.Parse(id); parm1.Direction = ParameterDirection.Input; sqlCmd.Parameters.Add(parm1); sqlAdap.SelectCommand = sqlCmd; DataSet ds = new DataSet(); sqlAdap.Fill(ds); DataRow dr = ds.Tables[0].Rows[0]; p = new Data.Pemeriksaan { Id = (int)dr["Id"], LembagaId = dr["LembagaId"].ToString() }; for (int i = 0; i < ds.Tables[1].Rows.Count; i++) { Data.PemeriksaanDetail pd = new Data.PemeriksaanDetail { Id = int.Parse(ds.Tables[1].Rows[i]["Id"].ToString()), StockRegId = int.Parse(ds.Tables[1].Rows[i]["StockRegId"].ToString()), CurrentBalance = int.Parse(ds.Tables[1].Rows[i]["Balance"].ToString()), ParasMenokok = int.Parse(ds.Tables[1].Rows[i]["ParasMenokok"].ToString()), StockId = int.Parse(ds.Tables[1].Rows[i]["StockId"].ToString()), StockCode = ds.Tables[1].Rows[i]["StockRegNo"].ToString(), StockName = ds.Tables[1].Rows[i]["StockDetail"].ToString() }; p.Details.Add(pd); } //DataRow drDetail = ds.Tables[0].Rows[0]; return string.Empty; } catch (Exception err) { return err.Message; } finally { sqlConn.Close(); sqlConn.Dispose(); sqlCmd.Dispose(); } }
private void Save(string CurrUser) { try { var glLembagaName = FindControlRecursive(this, "glLembagaName") as ASPxGridLookup; var gvSenaraiStok = FindControlRecursive(this, "gvSenaraiStok") as ASPxGridView; Data.Pemeriksaan p = new Data.Pemeriksaan { LembagaId = glLembagaName.Value.ToString(), }; for (int i = 0; i < gvSenaraiStok.VisibleRowCount; i++) { Data.PemeriksaanDetail sr = new Data.PemeriksaanDetail(); sr.StockRegId = int.Parse(gvSenaraiStok.GetRowValues(i, "Id").ToString()); p.Details.Add(sr); } string err = Core.Stor.PemeriksaanMethods.SP_PemeriksaanSave(int.Parse(CurrUser), p); if (err == "") { cbp_Main.JSProperties["cpErrMsg"] = string.Empty; } else { string errMsg = ConfigurationManager.AppSettings["ErrorMessageStaringSentenceDBError"].ToString(); errMsg = errMsg.Replace("BR", "<br><br>"); cbp_Main.JSProperties["cpErrMsg"] = errMsg + " " + err; } } catch (Exception err) { string errMsg = ConfigurationManager.AppSettings["ErrorMessageStaringSentenceCaughtByExceptions"].ToString(); errMsg = errMsg.Replace("BR", "<br><br>"); cbp_Main.JSProperties["cpErrMsg"] = errMsg + " " + err; } finally { } }
private void LoadStock(Data.Pemeriksaan p) { List<Data.PemeriksaanDetail> srs = new List<Data.PemeriksaanDetail>(); try { for (int x = 0; x < p.Details.Count; x++) { Data.PemeriksaanDetail sr = new Data.PemeriksaanDetail(); sr.Id = p.Details[x].StockRegId; sr.StockId = p.Details[x].StockId; sr.StockCode = p.Details[x].StockCode; sr.StockName = p.Details[x].StockName; sr.CurrentBalance = p.Details[x].CurrentBalance; sr.ParasMenokok = p.Details[x].ParasMenokok; srs.Add(sr); } Tab_Pemeriksaan_Controller1.BindSenaraiStok(srs); cbp_Main.JSProperties["cpErrMsg"] = string.Empty; } catch (Exception err) { string errMsg = ConfigurationManager.AppSettings["ErrorMessageStaringSentenceCaughtByExceptions"].ToString(); errMsg = errMsg.Replace("BR", "<br><br>"); cbp_Main.JSProperties["cpErrMsg"] = errMsg + " " + err.Message; } finally { } }
private void AddStock() { List<Data.PemeriksaanDetail> srs = new List<Data.PemeriksaanDetail>(); try { var gvSearchStockReg = FindControlRecursive(this, "gvSearchStockReg") as ASPxGridView; if (gvSearchStockReg.Selection.Count == 0) { cbp_Main.JSProperties["cpErrMsg"] = string.Empty; return; } for (int x = 0; x < gvSearchStockReg.VisibleRowCount; x++) { if (gvSearchStockReg.Selection.IsRowSelected(x)) { Data.PemeriksaanDetail sr = new Data.PemeriksaanDetail(); sr.Id = int.Parse(gvSearchStockReg.GetRowValues(x, "StockRegId").ToString()); sr.StockId = int.Parse(gvSearchStockReg.GetRowValues(x, "StockId").ToString()); sr.StockCode = gvSearchStockReg.GetRowValues(x, "StockRegNo").ToString(); sr.StockName = gvSearchStockReg.GetRowValues(x, "StockDetail").ToString(); sr.CurrentBalance = int.Parse(gvSearchStockReg.GetRowValues(x, "Balance").ToString()); sr.ParasMenokok = int.Parse(gvSearchStockReg.GetRowValues(x, "ParasMenokok").ToString()); srs.Add(sr); } } Tab_Pemeriksaan_Controller1.BindSenaraiStok(srs); cbp_Main.JSProperties["cpErrMsg"] = string.Empty; } catch (Exception err) { string errMsg = ConfigurationManager.AppSettings["ErrorMessageStaringSentenceCaughtByExceptions"].ToString(); errMsg = errMsg.Replace("BR", "<br><br>"); cbp_Main.JSProperties["cpErrMsg"] = errMsg + " " + err.Message; } finally { } }