コード例 #1
0
        public static DbStatusEntity[] InsertData(OutwardEntryInsertParam1 obj1, OutwardEntryInsertParam2[] obj2)
        {
            var details = new List <DbStatusEntity>();

            try
            {
                details.Add(new OutwardEntryDAO().InsertOutwardEntry(obj1, obj2, Convert.ToInt64(HttpContext.Current.Session["USER_ID"])));
            }
            catch (Exception ex)
            {
                details.Clear();
                details.Add(new DbStatusEntity(ex.Message));
            }
            return(details.ToArray());
        }
コード例 #2
0
        public DbStatusEntity InsertOutwardEntry(OutwardEntryInsertParam1 obj, OutwardEntryInsertParam2[] obj2, Int64 userid)
        {
            DataTable      dtsub     = new DataTable();
            DbStatusEntity objreturn = new DbStatusEntity();
            string         CS        = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            try
            {
                dtsub.Columns.Add("CATALOG_ID", typeof(Int64));
                dtsub.Columns.Add("SKU", typeof(string));
                dtsub.Columns.Add("CODE", typeof(string));
                dtsub.Columns.Add("CATALOG_TITLE", typeof(string));
                dtsub.Columns.Add("QTY", typeof(double));
                dtsub.Columns.Add("REMARKS", typeof(string));
                dtsub.Columns.Add("GENID", typeof(string));
                foreach (OutwardEntryInsertParam2 ob in obj2)
                {
                    DataRow dr = dtsub.NewRow();
                    dr["CATALOG_ID"]    = ob.ID;
                    dr["SKU"]           = ob.SKU;
                    dr["CODE"]          = ob.CODE;
                    dr["CATALOG_TITLE"] = ob.TITLE;
                    dr["QTY"]           = ob.QTY;
                    dr["REMARKS"]       = ob.REMARKS;
                    dr["GENID"]         = ob.GENID;
                    dtsub.Rows.Add(dr);
                }
                dtsub.AcceptChanges();

                using (SqlConnection con = new SqlConnection(CS))
                {
                    SqlCommand cmd = new SqlCommand("USP_InsertOutwardEntry", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@LED_NAME", obj.LED_NAME);
                    cmd.Parameters.AddWithValue("@TRANS_DATE", obj.TRANS_DATE);
                    cmd.Parameters.AddWithValue("@REF_NO", obj.REF_NO);
                    cmd.Parameters.AddWithValue("@REMARKS", obj.REMARKS);
                    cmd.Parameters.AddWithValue("@USER_ID", userid);
                    cmd.Parameters.AddWithValue("@OUT_TYPE_NAME", obj.OUT_TYPE_NAME);

                    SqlParameter sqlParam = cmd.Parameters.AddWithValue("@TVP", dtsub);
                    sqlParam.SqlDbType = SqlDbType.Structured;

                    cmd.Parameters.Add("@RESULT", SqlDbType.Int);
                    cmd.Parameters["@RESULT"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@CNT", SqlDbType.Int);
                    cmd.Parameters["@CNT"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@MSG", SqlDbType.NVarChar, 500);
                    cmd.Parameters["@MSG"].Direction = ParameterDirection.Output;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    objreturn.RESULT = Convert.ToInt32(cmd.Parameters["@RESULT"].Value);
                    objreturn.CNT    = Convert.ToInt32(cmd.Parameters["@CNT"].Value);
                    objreturn.MSG    = Convert.ToString(cmd.Parameters["@MSG"].Value);
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(objreturn);
        }