- public List<LDNo> LDNoList(Int64? LDNo)
- {
- ResultModel result = new Models.ViewModel.CommonViewModel.ResultModel();
- string error = String.Empty;
- QUERY2 query = new QUERY2();
- Dictionary<string, object> dict = new Dictionary<string, object>();//= new Dictionary<string, string>
- List<LDNo> ldnoList = new List<LDNo>();
- dict.Add("@LDNO", LDNo);
- dict.Add("@Result", 1.ToString());
- dict.Add("@Message", "Message".ToString());
- query.SQL = @"SPROC_GET_tblDyesForecastingHead_LDNO";
- query.PARAMETER = dict;
- clsDataprocess cls = new clsDataprocess();
- result = cls.ExecuteSqlStoredProcedureSaveEdit(query, "get", out error);
- if (result.Result && result.DtTable != null && result.DtTable.Rows.Count > 0)
- {
- Int64 tempi = 0;
- for (int i = 0; i < result.DtTable.Rows.Count; i++)
- {
- LDNo lDNo = new LDNo();
- Int64.TryParse(result.DtTable.Rows[i]["LDNO"].ToString(), out tempi);
- lDNo.LdNo = tempi;
- ldnoList.Add(lDNo);
- }
- string Message = result.Message;
- string Result = result.Result.ToString();
- }
- else if (!result.Result)
- {
- throw new Exception(result.Message);
- }
- return ldnoList;
- }
- public class clsDataprocess
- {
- public ResultModel ExecuteSqlStoredProcedureSaveEdit(QUERY2 query, string getOrSaveEdit, out string ERROR)
- {
- ResultModel result = new ResultModel();
- SqlConnection con = getConnection253_Mymun();
- con.Open();
- try
- {
- SqlCommand command = new SqlCommand();
- command.Connection = con;
- command.CommandType = CommandType.StoredProcedure;
- command.CommandText = query.SQL;
- SqlParameter param = new SqlParameter();
- //param = command.Parameters.Add("@country", SqlDbType.VarChar, 50);
- param.Direction = ParameterDirection.InputOutput;
- //param.Value = "UK";
- if (query.PARAMETER != null)
- {
- foreach (KeyValuePair<string, object> data in query.PARAMETER)
- {
- if (data.Key == "@Message")
- {
- command.Parameters.Add(data.Key, SqlDbType.NVarChar, 200).Direction = ParameterDirection.Output;
- }
- else if (data.Key == "@Result")
- {
- command.Parameters.Add(data.Key, SqlDbType.Bit, 1).Direction = ParameterDirection.Output;
- }
- else if (data.Key == "@ID")
- {
- command.Parameters.Add(data.Key, SqlDbType.BigInt, 1).Direction = ParameterDirection.Output;
- }
- else
- {
- if (data.Value != null)
- command.Parameters.AddWithValue(data.Key, data.Value);
- else
- command.Parameters.AddWithValue(data.Key, DBNull.Value);
- }
- }
- }
- if (getOrSaveEdit == "saveedit")
- {
- result.returnedValueFromQuery = command.ExecuteNonQuery();
- if (command.Parameters.Contains("@ID"))
- {
- string s = command.Parameters["@ID"].Value.ToString();
- int ID = 0;
- int.TryParse(command.Parameters["@ID"].Value.ToString(), out ID);
- result.Id = ID;
- }
- result.Message = command.Parameters["@Message"].Value.ToString();
- result.Result = Convert.ToBoolean(command.Parameters["@Result"].Value.ToString());
- }
- else if (getOrSaveEdit == "get")
- {
- SqlDataReader dr = command.ExecuteReader();
- ERROR = String.Empty;
- ArrayList myArryList = new ArrayList();
- //dr.Read();
- var dt = new DataTable();
- bool FlagDataRead = false;
- while (dr.Read())
- {
- FlagDataRead = true;
- dt.Load(dr);
- myArryList.Add(dt);
- result.DtTable = dt;
- result.Result = Convert.ToBoolean(command.Parameters["@Result"].Value.ToString());
- result.Message = command.Parameters["@Message"].Value.ToString();
- if (!dr.IsClosed)
- {
- continue;
- }
- else
- {
- break;
- }
- }
- if (!FlagDataRead)
- {
- dr.NextResult();
- result.Result = Convert.ToBoolean(command.Parameters["@Result"].Value.ToString());
- result.Message = command.Parameters["@Message"].Value.ToString();
- }
- }
- ERROR = String.Empty;
- }
- catch (SqlException ex)
- {
- ERROR = ex.Message.ToString();
- result.Message = ex.Message.ToString();
- result.Result = false;
- }
- finally
- {
- con.Close();
- }
- return result;
- }
- // Get Connction
- public SqlConnection getConnection253_Mymun()
- {
- //string connStr = @"data source=(local);database=DBL_Group;uid=sa;password=dblgroup";
- //string connStr = @"data source=(local);database=ProjectInfoDB;Connection Timeout=3000;Integrated Security=True";
- //string connStr = @"data source=192.168.153.208;database=ProjectInfoDB;uid=sa;password=dbl1234";
- //string connStr = @"data source=MISDEVELOPER\SQL14;database=ProjectInfoDB;uid=sa;password=logon";
- string connStr = @"data source=192.168.13.253;database=ProjectInfoDB;uid=sa;password=DbL123"; // live server
- SqlConnection conn = new SqlConnection(connStr);
- return conn;
- }
- }
- public class QUERY2
- {
- public string SQL { get; set; }
- public Dictionary<string, object> PARAMETER { get; set; }
- public Dictionary<string, byte[]> BYTEPARAMETER { get; set; }
- }
- public class ResultModel
- {
- public int Id { get; set; }
- public int returnedValueFromQuery { get; set; }
- public string Message { get; set; }
- public bool Result { get; set; }
- public DataTable DtTable { get; set; }
- public ArrayList MyDataList { get; set; }
- }
- public class LDNo
- {
- public Int64 LdNo { get; set; }
- }
- USE [ProjectInfoDB]
- GO
- /****** Object: StoredProcedure [dbo].[SPROC_GET_tblDyesForecastingHead_LDNO] Script Date: 11/1/2018 1:08:11 PM ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: <Muhammad Ashikuzzaman,,Name>
- -- Create date: <14-08-2018,,>
- -- Edit date: < ,,>
- -- Description: <Initial server: 192.168.153.208 ,,>
- -- =============================================
- ALTER PROCEDURE [dbo].[SPROC_GET_tblDyesForecastingHead_LDNO]
- @LDNO bigint = null,
- @Result bit =1 out ,
- @Message nvarchar(200) = 'ok' out
- AS
- BEGIN
- SET NOCOUNT ON;
- --select top 50 CommonId_For_ForeCastingDetails, DyeingPart, DyesID from dbo.tblDyesForecastingDetail
- select DISTINCT LDNO from dbo.tblDyesForecastingHead
- where Convert(nvarchar(50), LDNO) like '%'+ Convert(nvarchar(50), ISNULL(@LDNO, LDNO) ) +'%'
- --select top 50 CommonId_For_ForeCastingDetails, DyeingPart, DyesID from dbo.tblDyesForecastingDetail
- If (@@ERROR<>0)
- Begin
- set @Result = 0
- set @Message = 'Failed to Retrieve, Try Again'
- End
- Else
- BEGIN
- set @Result = 1
- set @Message = 'Data was Retrieved successfully'
- END
- END
No comments:
Post a Comment