Exemplo n.º 1
0
        //Insert New Record
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            clsPOSDB  dp          = new clsPOSDB();
            DPDetails dpDetailRec = new DPDetails(0, txtDeliveryPointName.Text, txtDeliveryPointAddress.Text);

            EnableButtons();

            int iEmpId = dp.InsertDeliveryPoint(dpDetailRec);

            if (iEmpId != -1)
            {
                //FrmMain.statusBarMain.Text = "Record Saved Successfully";

                //Refresh Display after addition of record and
                //Display last record inserted
                UnBindControls();
                ShowAllRecords();
                BindControls();
                this.BindingContext[dpInfo].Position = dpInfo.Length - 1;
            }
            else
            {
                //FrmMain.statusBarMain.Text = "Save Operation Failed";
            }
        }
Exemplo n.º 2
0
        public int UpdateDeliveryPoint(DPDetails emp)
        {
            SqlConnection conn = new SqlConnection(connStr);
            SqlCommand    cmd  = conn.CreateCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "procUpdateDeliveryPoint";

            cmd.Parameters.Add(new SqlParameter("@DeliveryPointId", SqlDbType.Int));
            cmd.Parameters["@DeliveryPointId"].Value = emp.DeliveryPointId;

            cmd.Parameters.Add(new SqlParameter("@DeliveryPointName", SqlDbType.NVarChar, 20));
            cmd.Parameters["@DeliveryPointName"].Value = emp.DeliveryPointName;

            cmd.Parameters.Add(new SqlParameter("@DeliveryPointAddress", SqlDbType.NVarChar, 20));
            cmd.Parameters["@DeliveryPointAddress"].Value = emp.DeliveryPointAddress;

            try
            {
                conn.Open();
                int RecordsAffected = cmd.ExecuteNonQuery();
                return(RecordsAffected);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Data Error:" + ex);
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 3
0
        public DPDetails GetDeliveryPoint(int DeliveryPointId)
        {
            SqlConnection conn = new SqlConnection(connStr);
            SqlCommand    cmd  = conn.CreateCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "procGetDeliveryPointRec";

            cmd.Parameters.Add(new SqlParameter("@DeliveryPointId", SqlDbType.Int));
            cmd.Parameters["@DeliveryPointId"].Value = DeliveryPointId;

            try
            {
                conn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                DPDetails     emp;
                if (dr.Read())
                {
                    emp = new DPDetails((int)dr["DeliveryPointId"], (string)dr["DeliveryPointName"], (string)dr["DeliveryPointAddress"]);
                }
                else
                {
                    emp = null;
                }
                dr.Close();
                conn.Close();
                return(emp);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Data Error\n" + ex.Message);
            }
        }
Exemplo n.º 4
0
        //Returns Specific Record
        private void ShowRecord(int RecordId)
        {
            clsPOSDB  dp          = new clsPOSDB();
            DPDetails dpDetailRec = dp.GetDeliveryPoint(RecordId);

            if (dpDetailRec != null)
            {
                txtDeliveryPointId.Text      = dpDetailRec.DeliveryPointId.ToString();
                txtDeliveryPointName.Text    = dpDetailRec.DeliveryPointName;
                txtDeliveryPointAddress.Text = dpDetailRec.DeliveryPointAddress;
            }
            else
            {
                //FrmMain.statusBarMain.Text = "Record Not Found";
            }
        }
Exemplo n.º 5
0
        //Update Record
        private void btnUpdate_Click(object sender, System.EventArgs e)
        {
            clsPOSDB  dp          = new clsPOSDB();
            DPDetails dpDetailRec = new DPDetails(Convert.ToInt32(txtDeliveryPointId.Text), txtDeliveryPointName.Text, txtDeliveryPointAddress.Text);

            int iRecAffected = dp.UpdateDeliveryPoint(dpDetailRec);

            if (iRecAffected != 0)
            {
                //FrmMain.statusBarMain.Text = "Record Updated Successfully";
            }
            else
            {
                //FrmMain.statusBarMain.Text = "Update Operation Failed";
            }
        }
Exemplo n.º 6
0
        public DPDetails[] GetAllDeliveryPoint()
        {
            SqlConnection conn = new SqlConnection(connStr);
            SqlCommand    cmd  = conn.CreateCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "procGetAllDeliveryPoint";

            ArrayList arrEmp = new ArrayList();

            try
            {
                conn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                DPDetails     emp;
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        emp = new DPDetails((decimal)dr["DeliveryPointId"], (string)dr["DeliveryPointName"], (string)dr["DeliveryPointAddress"]);
                        arrEmp.Add(emp);
                    }
                }
                else
                {
                    emp = null;
                }
                dr.Close();
                conn.Close();
                return((DPDetails[])arrEmp.ToArray(typeof(DPDetails)));
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Data Error\n" + ex.Message);
            }
        }