示例#1
0
        public List <MyDepot> GetDepotMasterRecord(MyDepot Data)
        {
            DataTable dt = GetDepotMasterRecordValues(Data);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //int St = 0;
                //if (dt.Rows[i]["Status"].ToString() != "")
                //{
                //    St = Int32.Parse(dt.Rows[i]["Status"].ToString());
                //}
                //else
                //{
                //    St = 0;
                //}
                ListDepot.Add(new MyDepot
                {
                    ID         = Int32.Parse(dt.Rows[i]["ID"].ToString()),
                    DepName    = dt.Rows[i]["DepName"].ToString(),
                    DepAddress = dt.Rows[i]["DepAddress"].ToString(),
                    DepCountry = Int32.Parse(dt.Rows[i]["DepCountry"].ToString()),
                    DepCity    = Int32.Parse(dt.Rows[i]["DepCity"].ToString()),
                    Status     = Int32.Parse(dt.Rows[i]["Status"].ToString()),
                });
            }


            return(ListDepot);
        }
示例#2
0
        public List <MyDepot> DepotRecord(MyDepot Data)
        {
            MasterManager  cm = new MasterManager();
            List <MyDepot> st = cm.GetDepotMasterRecord(Data);

            return(st);
        }
示例#3
0
        public List <MyDepot> Depot(MyDepot Data)
        {
            MasterManager  cm = new MasterManager();
            List <MyDepot> st = cm.InsertDepotMaster(Data);

            return(st);
        }
示例#4
0
        public List <MyDepot> GetDepotMaster(MyDepot Data)
        {
            DataTable dt = GetDepotSearchValues(Data);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ListDepot.Add(new MyDepot
                {
                    ID             = Int32.Parse(dt.Rows[i]["ID"].ToString()),
                    DepName        = dt.Rows[i]["DepName"].ToString(),
                    DepCountryName = dt.Rows[i]["CountryV"].ToString(),
                    DepCityName    = dt.Rows[i]["CityV"].ToString(),
                    StatusName     = dt.Rows[i]["StatusV"].ToString()
                });
            }
            return(ListDepot);
        }
示例#5
0
        public DataTable GetDepotSearchValues(MyDepot Data)
        {
            string strWhere = "";

            string _Query = " Select ID,DepName,(select CountryName from NVO_CountryMaster where ID= DepCountry) as CountryV, " +
                            " (select CityName from NVO_CityMaster where ID = DepCity) as CityV, " +
                            " Case when Status = 0 then 'Inactive' else 'Active' end as StatusV " +
                            " from NVO_DepotMaster";

            if (Data.DepName != "")
            {
                if (strWhere == "")
                {
                    strWhere += _Query + " where DepName like '%" + Data.DepName + "%'";
                }
                else
                {
                    strWhere += " and DepName like '%" + Data.DepName + "%'";
                }
            }



            if (Data.Status.ToString() == "1")
            {
                if (strWhere == "")
                {
                    strWhere += _Query + " where Status =" + Data.Status.ToString();
                }
            }


            if (strWhere == "")
            {
                strWhere = _Query;
            }

            return(GetViewData(strWhere, ""));
        }
示例#6
0
        public DataTable GetDepotMasterRecordValues(MyDepot Data)
        {
            string _Query = "select *  from NVO_DepotMaster where ID=" + Data.ID;

            return(GetViewData(_Query, ""));
        }
示例#7
0
        public List <MyDepot> InsertDepotMaster(MyDepot Data)
        {
            DbConnection  con = null;
            DbTransaction trans;

            try
            {
                con = _dbFactory.GetConnection();
                con.Open();
                trans = _dbFactory.GetTransaction(con);
                DbCommand Cmd = _dbFactory.GetCommand();
                Cmd.Connection  = con;
                Cmd.Transaction = trans;

                try
                {
                    Cmd.CommandText = " IF((select count(*) from NVO_DepotMaster where ID=@ID)<=0) " +
                                      " BEGIN " +
                                      " INSERT INTO  NVO_DepotMaster(DepName,DepAddress,DepCountry,DepCity,Status) " +
                                      " values (@DepName,@DepAddress,@DepCountry,@DepCity,@Status) " +
                                      " END  " +
                                      " ELSE " +
                                      " UPDATE NVO_DepotMaster SET DepName=@DepName,DepAddress=@DepAddress,DepCountry=@DepCountry,DepCity=@DepCity,Status=@Status where ID=@ID";

                    Cmd.Parameters.Add(_dbFactory.GetParameter("@ID", Data.ID));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@DepName", Data.DepName));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@DepAddress", Data.DepAddress));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@DepCountry", Data.DepCountry));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@DepCity", Data.DepCity));
                    Cmd.Parameters.Add(_dbFactory.GetParameter("@Status", Data.Status));

                    int result = Cmd.ExecuteNonQuery();

                    Cmd.CommandText = "select ident_current('NVO_DepotMaster')";
                    if (Data.ID == 0)
                    {
                        Data.ID = Int32.Parse(Cmd.ExecuteScalar().ToString());
                    }
                    else
                    {
                        Data.ID = Data.ID;
                    }

                    trans.Commit();
                    return(ListDepot);
                }
                catch (Exception ex)
                {
                    string ss = ex.ToString();
                    trans.Rollback();
                    return(ListDepot);
                }
            }


            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                if (con != null && con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }