Exemplo n.º 1
0
        public List <Supliers> GetAllCustomers()
        {
            var    _SupliersList = new List <Supliers>();
            string query         = ("Select *From Supliers");
            var    reader        = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var _Supliers = new Supliers();
                    _Supliers.Id            = Convert.ToInt32(reader["Id"].ToString());
                    _Supliers.Code          = (reader["Code"].ToString());
                    _Supliers.Name          = reader["Name"].ToString();
                    _Supliers.Email         = reader["Email"].ToString();
                    _Supliers.Address       = reader["Address"].ToString();
                    _Supliers.Contact       = reader["Contact"].ToString();
                    _Supliers.ContactPerson = (reader["ContactPerson"].ToString());
                    _Supliers.Images        = reader["Images"].ToString();

                    _SupliersList.Add(_Supliers);
                }
            }
            reader.Close();

            return(_SupliersList);
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                SuplierImageFileUpload.SaveAs(Server.MapPath("~/Party/Images/") + Path.GetFileName(SuplierImageFileUpload.FileName));
                String GetImagePaths = "~/Party/Images/" + Path.GetFileName(SuplierImageFileUpload.FileName);

                Supliers _Supliers = new Supliers();
                _Supliers.Code          = txtCode.Text;
                _Supliers.Name          = txtName.Text;
                _Supliers.Email         = txtEmail.Text;
                _Supliers.Address       = txtAddress.Text;
                _Supliers.Contact       = txtContact.Text;
                _Supliers.ContactPerson = (txtContactPerson.Text);
                _Supliers.Images        = GetImagePaths;

                if (IdHiddenField.Value == "")
                {
                    decimal AlreadyExistCustomer = _SuplierRepository.AlreadyExistSuplier(_Supliers);
                    if (AlreadyExistCustomer >= 1)
                    {
                        ShowMessage("This Suplier Already Here!!...Enter Another Name", MessageType.Warning);
                    }
                    else
                    {
                        int Savesuccess = _SuplierRepository.Add(_Supliers);
                        if (Savesuccess > 0)
                        {
                            ShowMessage("Successfully Save Suplier!!...Continue Working", MessageType.Success);
                            IdHiddenField.Value = "";
                            Refresh();
                            AutoCodeGenerate();
                            LoadSuplier();
                        }
                        else
                        {
                            ShowMessage("Failed Suplier Saved!!...Try Again", MessageType.Failed);
                        }
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, MessageType.Error);
            }
        }
Exemplo n.º 3
0
        public Supliers LastExistCode()
        {
            Supliers _Supliers = null;

            string query  = "select top 1 Code from Supliers order by Code desc";
            var    reader = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                reader.Read();
                _Supliers      = new Supliers();
                _Supliers.Code = (reader["Code"].ToString());
            }
            reader.Close();

            return(_Supliers);
        }
        public List <Supliers> GetAllSupliers()
        {
            var    _SupliersList = new List <Supliers>();
            string query         = ("Select *From Supliers");
            var    reader        = _MainRepository.Reader(query, _MainRepository.ConnectionString());

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var _Supliers = new Supliers();
                    _Supliers.Id   = Convert.ToInt32(reader["Id"].ToString());
                    _Supliers.Name = reader["Name"].ToString();

                    _SupliersList.Add(_Supliers);
                }
            }
            reader.Close();

            return(_SupliersList);
        }
Exemplo n.º 5
0
        public DataProvider()
        {
            DB = DBUtils.GetDBConnection();
            try
            {
                Console.WriteLine("Openning Connection ...");
                DB.Open();
                Units        = new Units();
                Supliers     = new Supliers();
                Customers    = new Customers();
                Products     = new Products();
                InputInfoes  = new InputInfoes();
                Inputs       = new Inputs();
                OutputInfoes = new OutputInfoes();
                Outputs      = new Outputs();
                Console.WriteLine("Connection successful!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.Read();
        }
Exemplo n.º 6
0
        public int Delete(Supliers _Supliers)
        {
            string query = ("Delete From Supliers Where Code ='" + _Supliers.Code + "' ");

            return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString()));
        }
Exemplo n.º 7
0
        public int Update(Supliers _Supliers)
        {
            string query = "Update Supliers SET  Name='" + _Supliers.Name + "' WHERE Code='" + _Supliers.Code + "' ";

            return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString()));
        }
Exemplo n.º 8
0
        public int Add(Supliers _Supliers)
        {
            string query = "Insert Into Supliers(Code,Name,Email,Address,Contact,ContactPerson,Images) Values ('" + _Supliers.Code + "','" + _Supliers.Name + "','" + _Supliers.Email + "','" + _Supliers.Address + "','" + _Supliers.Contact + "','" + _Supliers.ContactPerson + "','" + _Supliers.Images + "')";

            return(_MainRepository.ExecuteNonQuery(query, _MainRepository.ConnectionString()));
        }
Exemplo n.º 9
0
        public decimal AlreadyExistSuplier(Supliers _Supliers)
        {
            string query = "Select Count(*)from Supliers Where Name='" + _Supliers.Name + "' And Contact='" + _Supliers.Contact + "'";

            return(_MainRepository.ExecuteScalar(query, _MainRepository.ConnectionString()));
        }